Why do images have distros?

Hi

I’ve a few days playing with Docker and now that I was going to start a project got really confused.

I was going to use a Nginx image and looking into the tags file I’ve noticed each one has a distro included like debian and alpine… Why?

I mean, why if I will have a distro installed on my server would I want to have another one into Docker? Isn’t that bad for performance, to have two distros running at the same time?

I’ve tried to find a Nginx image without distro without luck. Can I make one myself or do it need to have a distro included?

I haven’t found info about this particularly, so I’ll be glad if you can comment on this, thanks.

Well I just found this https://stackoverflow.com/questions/45177473/docker-container-does-not-need-an-os-but-each-container-has-one-why

One answer says “Docker behind the scene uses the host OS which is linux itself to run its containers. The programs included in linux-like filesystem snapshot that we see in form of docker containers actually runs on the host OS in isolation

What I get is… As the container runs as a process of the host, then the host and container runs simultaneously sharing resources and sub-processes. Then, do the host and container use the same distro?

Simply put, a docker container is nothing else than an isolation process on the hosts kernel (not the os!). If the application inside the image is staticly compiled and requires no os level dependencies, an image does not necessarily require to base on an os image.

Usualy people base their images on os base images they are familiar with, to install dependencies. A container has no own kernel and is not booted - thus, it only has the binaries of the os, but does not provide all services you are used from the os. Only the application declared as entrypoint/command is started (which again can spawn subprocesses if needed), nothing else!

1 Like