2

Sorry if this is a silly question, but:

I came from vagrant where we have a full featured OS in each machine, where running ps -aux we can see the OS processes and our services (I know to some extent the difference between applications running in VMs and Docker).

Then I've just built some containers using docker-compose and logged in into a container using bash (which is based on debian:jessie image). After running ps -auxI can only see the services I installed, not a single OS's process. Why? Where they are? How this works?

Docker has a VM in which the containers run, each container may be based on a different distribution, so, is the OS containerized also, giving the fact the there's the host's OS (VM) for docker?

Valdir
  • 495
  • 2
  • 7
  • 20
  • 1
    Whenever you hear "Docker container", just think "normal process, but with a bunch of things (filesystem, processes, network stuff, etc.) sandboxed via namespacing". – Oliver Charlesworth May 30 '18 at 20:50
  • @OliverCharlesworth So actually the debian:jessie docker's image is not an OS but a simulation of it in a single process? – Valdir May 30 '18 at 20:54
  • 1
    Basically, all you're getting is a filesystem that looks like the filesystem on a "real" Jessie system (on top of the standard Docker functionality - sandboxed networks, etc.) There's no emulation/simulation going on. – Oliver Charlesworth May 30 '18 at 20:55

1 Answers1

3

Docker has a VM in which the containers run

Nope, containers are not VMs (docker includes a VM for desktop versions, but that isn't a container, and there are VM runtimes, but that's not a traditional container).

Containers are a way to isolate a running application with kernel namespaces for things like the filesystem, pids, and network. They all run in the same kernel. Pulling a base image for Alpine, Ubuntu, etc, gives you the base filesystem, libraries, package managers, but not the kernel. The only process launched inside a container is your application, and when your application exits, so does the container. Therefore you won't see OS utilities running.

See also this answer

BMitch
  • 231,797
  • 42
  • 475
  • 450