I don't understand the difference between docker and chroot. Yes its nice in terms of the packaging the registry. But somehow I get the feeling its just chroot with extra bells and whistles.

I know I'm missing something. It'd would be great to know how they are different and the need of docker if chroot could do something similar.

I couldn't find this Chroot Vs Docker clear enough either.

  • Well, yes, Docker doesn't do anything that the kernel won't already do for you. It just packages it into a more-or-less coherent and fairly easy to use tool. You could make your own Docker if you could be bothered to do chroot, namespaces, quotas, NAT, and all the rest yourself.
    – Gaius
    Dec 8 '17 at 21:28

Well, the extra bells and whistles is called process isolation, a container gets its own namespace from the host kernel, that means the program in the container can't try to read kernel memory or eat more RAM than allowed.

It also isolate network stacks, so two process can listen on port 8080 for exemple, you'll have to handle the routing at host level, there's no magic here, but this allow handling the routing at one place and avoid modifying the process configuration to listen to a free port.

Secondly a chroot is still read/write, any change is permanent, a docker container using aufs will start from a clean filesystem each time you launch the container (changes are kept if you stop/start it IIRC).

So while a container may be thought of as process namespace + chroot, the reality is a little more complex.

  • Note that aufs is not used by default anymore. Now it's overlay2 Dec 8 '17 at 17:30
  • True, but I think there's more educational materials referencing aufs than overlay2 for now :)
    – Tensibai
    Dec 8 '17 at 19:16
  • A normal process can't read any memory it's not supposed to either. If you are relying on Docker for security you're doing it wrong...
    – Gaius
    Dec 10 '17 at 17:07
  • @Gaius you're reading me wrong, I'm just trying to give search clues to the OP... Adding docker in a delivery pipeline with all the freedom it give to developer to what they use inside is absolutely not a security point. Nonetheless namespaces protect from a bunch of stack overflow and buffer overflow by nature.
    – Tensibai
    Dec 10 '17 at 19:08

Yes, there absolutely is more to it than chroot to the point that they have little to nothing in common.

  • A standardized script file format including semantics relating to the task a hand
  • Images (including anonymous in-between images), caching, naming, downloading etc. including powerful management (docker image prune ...)
  • Containers (including their own temporary file systems, naming, being able to docker exec into them etc.)
  • Process management (docker container ...)
  • Networking with just a simple option, including intra-docker-container-networking etc.
  • Volumes (including special managed volumes)
  • docker-compose or swarm as low-profile upgrades to much more.
  • The large zoo of other solutions based on dockerized containers (OpenShift etc.).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.