Spinning up a Docker container the way I'm kind of assuming you are talking about is going to involve running the compiler in there, which is super annoying -- and extremely limited, as you often are going to get stuck with old versions of all of your toolchain components as well -- and certainly way more difficult than just extracting the distribution to disk and using gcc --sysroot=/path/to/glibc-2.31.
saurik|4 months ago