Determine the parent image

New docker user here who just registered - because I have pretty much the same question. So apologies for the thread hijack - I’ll start a new thread if you want.

My best research so far has led me to this previous thread…

https://forums.docker.com/t/how-to-build-c-image-in-a-container/37668

I’ve found a few other snippits with my googling over the last day or so.

So the way I’m understanding it (and have succeeded with a basic c ‘hello world’ app) is there are two ways.

Using FROM scratch - compile the C program entirely statically (use -static and ldd on the exe says ‘not a dynamic executable’ - probably will require glibc-static in your c build environment). Then docker build and run the container.

If not compiling statically then use your base linux image FROM , Depending on dependencies you may need to yum / apt additional libs / dependencies.

I’m struggling right now to get my head round what is the ‘best practice’ way from the above methods? Statically building a big old C/C++ exe is usually frowned upon in C developer circles. But container size at least for a simple app seems a lot leaner than one from a Linux base image.

Anyone more with experience suggest the best practice or another?

TIA