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,

  • WordPress's wp-admin panel weird behavior
  • Getting “FATAL: role ”root“ does not exist” when trying to do “docker up”
  • How to update software inside a docker container?
  • Dockerfile Script for Amazon AWS
  • Finding a string in docker logs of container
  • boot2docker access elasticsearch on localhost
  • Chaning tcp_keepalive_* inside a docker container
  • Permission denied for Dockerfile while using Custom Build Environment Plugin
  • LogStash container restarts on Kube pod
  • How to correlate Docker image list with tag list both as returned by API?
  • NGINX & Consul-Template in Docker
  • Configuring options for docker run
  • 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.