Docker confusion

I am very interested in docker and I’ve read about it but I’m a bit confused with containers. When we pull for instance, the official nginx from docker hub, is it only the application or nginx comes with operating system? It seems to me that all containers come with the operating system since with docker exec -it app-name bash i can enter and make updates or install packages. This part is confusing to me because I had the idea that it was only the application and nothing else.

thank you,

  • EC2 User Data runs script but does not boot up application
  • Deleting docker images manually
  • Docker-Machine stuck on creating default
  • Is it possible for a the host to authenticate to a KDC running on a Docker container?
  • Docker Container Failing To Start On Boot
  • Bash command to list all docker images in a remote registry
  • Cannot find the enviromental parameter
  • boot2docker command works on shell, but not in script
  • Kubernetes authentication issues pulling ECR images
  • Docker public registry push fails: Repository does not exist
  • Access an application running in a Docker Container which is running inside an emulated CoreOS in Ubuntu
  • What is the difference between docker Swarm and Swarm mode?
  • 2 Solutions collect form web for “Docker confusion”

    It depends. Most software needs some parts of the operating system to run (which can be some libraries, or utilities); in those cases, a “base” operating system is used (Debian or Alpine for the official images), so that the application can run. Although you’re able to docker exec into such a container and start a bash/shell session, this should only be used for debugging; in general the container (nginx) should be considered as the application nginx, not as a “virtual machine with nginx installed”.

    Some software is statically linked and doesn’t need additional things to be installed. For example, the hello-world or the traefik image do not use an operating system as a base, and only contain a single binary, nothing else.

    It depends of what you call the “OS”. Is you mean both kernel space and user space – answer is no. Containers change user space only.

    Docker works like chroot or lxc, it uses single Linux kernel from host and binaries/libraries/etc in containers to run, containers in nutshell are isolated namespaces on single machine.
    So, “OS” will never change in case if containers, but "environmnet" will change (libc, shells, all that stuff).
    Also, check this wiki article about cgroups.
    PS: sure, when you’re not on Linux you need to install VM with Linux to use Docker. But this is another question.

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