When we execute docker run ubuntu:14.04 ps ax, where does ps ax command runs?
I am new to docker and have been reading the docs and i understand the concept of userspace and kernel space. so when we run the above command i.e. docker run ubutnu:14.04, it download a ubutnu image(which does not have kernel) and runs it inside the container and then fires the command ps ax. my question is where the ps ax command executes? does it execute on the host OS(which is a linux kernel as docker runs on linux) or does it execute inside the container and shows all the processes running in the ubuntu user-space ?
One Solution collect form web for “When we execute docker run ubuntu:14.04 ps ax, where does ps ax command runs?”
The output of the
ps command should answer that question quite clearly. Here is
ps ax running on my host:
$ ps ax PID TTY STAT TIME COMMAND 1 ? Ss 0:10 /usr/lib/systemd/systemd --switched-root --system --deserialize 23 2 ? S 0:00 [kthreadd] 3 ? S 0:08 [ksoftirqd/0] 7 ? S 2:20 [rcu_sched] 8 ? S 0:00 [rcu_bh] 9 ? S 1:31 [rcuos/0] 10 ? S 0:00 [rcuob/0] [...many lines later...] 20565 pts/3 R+ 0:00 ps ax
And here it is running with
$ docker run ubuntu ps ax PID TTY STAT TIME COMMAND 1 ? Rs+ 0:00 ps ax
When you run
docker run ubuntu:14.04 ps ax, your are running the
ps command inside the container, and
ps will only be able to see other processes running inside the same container.