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,

  • Custom fonts in rrdgraph in a Docker container running Alpine Linux
  • can't connect inside a mongdb docker with pymongo
  • Restore database state after integration test using Docker?
  • Kubernetes for a Development Environment
  • Ubuntu/UFW: How to tell Docker not to expose all ports?
  • Docker: How to save running instance?
  • Docker Swarm vs. Docker Cluster
  • Apache2 Container on BlueMix won't stay up
  • Can I put kubernetes in a docker container?
  • How can I setup Docker container with individual IP address on EC2 instance?
  • Do not download all Maven dependencies on a Docker build
  • Difference between Docker for AWS and Docker Cloud?
  • 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.