I am starting to understand Docker and as far as I am aware the docker container runs on the default Linux dist where the container is installed - in my case it's a Mac OS X lightweight dist that comes with docker toolbox.
So why do I see many Docker files actually installing a distrib inside the container, does this not defeat the object of keeping things light?
For example, here is one Docker file starting with:
FROM debian:jessie
so this is installing a Docker image inside the container which is based on Debian.
I also see many others using Ubuntu, for example.
Can this step not be bypassed and software installed directly in the container use the underlining Linux dist where the container is installed?
Because, just as for physical or virtual machines, setting up a userland environment is going to be a pain without a distribution.
This is, IMO, one of the strong benefits of docker: Pick the most suitable distribution for a particular application.
A containerized application is probably going to have dependencies. To install these dependencies, it helps a lot to have a package manager. Some dependencies are also included by default in many distributions, which makes it a good idea for the container creator (application) to choose its own distribution.
Additionally, remember that packaging a whole distribution does not necessarily waste a lot of resources:
debian:jessie
could reuse the same data for the baseline.If you really want to create a minimal image, try busybox
. However, you will oftentimes find yourself outgrowing it quite fast for any real world container image.