Docker: why installing a linux dist inside the container?

I am starting to understand docker and as far as I am aware the docker container runs on the defualt linux dist where the container is installed – in my case its a mac os x lightweight dist thats 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?

  • What is the difference between volumes-from and volumes?
  • NoClassDefFoundError in Tomcat for Abstract Class
  • How can I setup monitoring of Docker Container from Nagios
  • Docker container run error: Container exited on error: exited with status 1
  • Cross-compile using go build CGO_ENABLED - warning: libudev.so.1 not found
  • how to detach from a docker container
  • 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 off of debian.

    I also see many others usign 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 installer?

    Thanks in advance for any clarification

  • Unable to login into private docker registry (v2.0)
  • What is /dev/mapper/vg_root-lv_root directory? Why my docker relies on this directory?
  • Docker-compose config front-end with back-end's IP from host's perspective
  • Bunyan logger on aws leaks file descriptors
  • How to resize docker container's cpu-share value dynamiclly?
  • Network configuration docker PHP API
  • One Solution collect form web for “Docker: why installing a linux dist inside the container?”

    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:

    • Docker images are stored as deltas against a common baseline, meaning that two images based on debian:jessie could reuse the same data for the baseline.
    • Distributions are actually not that large, as they are usually minified versions of the full system images.

    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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.