How can I see the real process inside the container in my host machine?
up vote
0
down vote
favorite
I start a container in my Mac e.g. docker run -it ubuntu:latest /bin/bash
I can find the pid of /bin/bash
from docker inspect but I can not find the real PID of the /bin/bash
in my mac.
To give another example:
docker run -it ubuntu:latest /bin/bash
sleep 2000&
If I then do in the host machine ps -ef | grep sleep
I can not find the sleep
process.
I think that in Linux the processes are visible. How does it work on Macs?
macos docker docker-container
add a comment |
up vote
0
down vote
favorite
I start a container in my Mac e.g. docker run -it ubuntu:latest /bin/bash
I can find the pid of /bin/bash
from docker inspect but I can not find the real PID of the /bin/bash
in my mac.
To give another example:
docker run -it ubuntu:latest /bin/bash
sleep 2000&
If I then do in the host machine ps -ef | grep sleep
I can not find the sleep
process.
I think that in Linux the processes are visible. How does it work on Macs?
macos docker docker-container
There's a virtual machine: a key part of "Docker containers share the host's kernel" is that there must be an actual Linux kernel in the stack somewhere.
– David Maze
Nov 10 at 19:36
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I start a container in my Mac e.g. docker run -it ubuntu:latest /bin/bash
I can find the pid of /bin/bash
from docker inspect but I can not find the real PID of the /bin/bash
in my mac.
To give another example:
docker run -it ubuntu:latest /bin/bash
sleep 2000&
If I then do in the host machine ps -ef | grep sleep
I can not find the sleep
process.
I think that in Linux the processes are visible. How does it work on Macs?
macos docker docker-container
I start a container in my Mac e.g. docker run -it ubuntu:latest /bin/bash
I can find the pid of /bin/bash
from docker inspect but I can not find the real PID of the /bin/bash
in my mac.
To give another example:
docker run -it ubuntu:latest /bin/bash
sleep 2000&
If I then do in the host machine ps -ef | grep sleep
I can not find the sleep
process.
I think that in Linux the processes are visible. How does it work on Macs?
macos docker docker-container
macos docker docker-container
asked Nov 10 at 17:40
Jim
2717
2717
There's a virtual machine: a key part of "Docker containers share the host's kernel" is that there must be an actual Linux kernel in the stack somewhere.
– David Maze
Nov 10 at 19:36
add a comment |
There's a virtual machine: a key part of "Docker containers share the host's kernel" is that there must be an actual Linux kernel in the stack somewhere.
– David Maze
Nov 10 at 19:36
There's a virtual machine: a key part of "Docker containers share the host's kernel" is that there must be an actual Linux kernel in the stack somewhere.
– David Maze
Nov 10 at 19:36
There's a virtual machine: a key part of "Docker containers share the host's kernel" is that there must be an actual Linux kernel in the stack somewhere.
– David Maze
Nov 10 at 19:36
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
I would say you don't. At least not with ps -ef | grep sleep
from the host machine.
This might work:
docker run -it --rm --name coolname ubuntu:latest /bin/bash
sleep 2000&
host machine:
docker exec -it coolname ps -ef | grep sleep
on a Mac you can go a step deeper as docker "native" is actually a minimal linux distro. That image is the actual "shared resource". You can get into that image with a command like screen
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
now if you do the following in a terminal:
docker run -it alpine /bin/sh
sleep 424242&
log in to the native image as described above. You will see the sleep command something like this will be the result:
linuxkit-025000000001:~# ps -ef|grep sleep
3190 root 0:00 sleep 424242
3193 root 0:00 grep sleep
so it is actually possible to see the shared resource. So it should also work on Linux but then it might be fully native.
How it works on windows I can't tell :-)
That returns the pid inside the container. I know how to find that. But there should be a sleep running at the host level. I am looking for that pid
– Jim
Nov 11 at 15:00
Just updated my answer a bit... hope that helps
– Ivonet
Nov 11 at 19:38
On Linux each process is run on the host machine. So there is no need to do the screen to get the pid. So I guess in mac there is only 1 process for docker and all the rest forked processes somehow are hidden and not show up as child processes?
– Jim
Nov 11 at 22:46
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
I would say you don't. At least not with ps -ef | grep sleep
from the host machine.
This might work:
docker run -it --rm --name coolname ubuntu:latest /bin/bash
sleep 2000&
host machine:
docker exec -it coolname ps -ef | grep sleep
on a Mac you can go a step deeper as docker "native" is actually a minimal linux distro. That image is the actual "shared resource". You can get into that image with a command like screen
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
now if you do the following in a terminal:
docker run -it alpine /bin/sh
sleep 424242&
log in to the native image as described above. You will see the sleep command something like this will be the result:
linuxkit-025000000001:~# ps -ef|grep sleep
3190 root 0:00 sleep 424242
3193 root 0:00 grep sleep
so it is actually possible to see the shared resource. So it should also work on Linux but then it might be fully native.
How it works on windows I can't tell :-)
That returns the pid inside the container. I know how to find that. But there should be a sleep running at the host level. I am looking for that pid
– Jim
Nov 11 at 15:00
Just updated my answer a bit... hope that helps
– Ivonet
Nov 11 at 19:38
On Linux each process is run on the host machine. So there is no need to do the screen to get the pid. So I guess in mac there is only 1 process for docker and all the rest forked processes somehow are hidden and not show up as child processes?
– Jim
Nov 11 at 22:46
add a comment |
up vote
2
down vote
I would say you don't. At least not with ps -ef | grep sleep
from the host machine.
This might work:
docker run -it --rm --name coolname ubuntu:latest /bin/bash
sleep 2000&
host machine:
docker exec -it coolname ps -ef | grep sleep
on a Mac you can go a step deeper as docker "native" is actually a minimal linux distro. That image is the actual "shared resource". You can get into that image with a command like screen
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
now if you do the following in a terminal:
docker run -it alpine /bin/sh
sleep 424242&
log in to the native image as described above. You will see the sleep command something like this will be the result:
linuxkit-025000000001:~# ps -ef|grep sleep
3190 root 0:00 sleep 424242
3193 root 0:00 grep sleep
so it is actually possible to see the shared resource. So it should also work on Linux but then it might be fully native.
How it works on windows I can't tell :-)
That returns the pid inside the container. I know how to find that. But there should be a sleep running at the host level. I am looking for that pid
– Jim
Nov 11 at 15:00
Just updated my answer a bit... hope that helps
– Ivonet
Nov 11 at 19:38
On Linux each process is run on the host machine. So there is no need to do the screen to get the pid. So I guess in mac there is only 1 process for docker and all the rest forked processes somehow are hidden and not show up as child processes?
– Jim
Nov 11 at 22:46
add a comment |
up vote
2
down vote
up vote
2
down vote
I would say you don't. At least not with ps -ef | grep sleep
from the host machine.
This might work:
docker run -it --rm --name coolname ubuntu:latest /bin/bash
sleep 2000&
host machine:
docker exec -it coolname ps -ef | grep sleep
on a Mac you can go a step deeper as docker "native" is actually a minimal linux distro. That image is the actual "shared resource". You can get into that image with a command like screen
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
now if you do the following in a terminal:
docker run -it alpine /bin/sh
sleep 424242&
log in to the native image as described above. You will see the sleep command something like this will be the result:
linuxkit-025000000001:~# ps -ef|grep sleep
3190 root 0:00 sleep 424242
3193 root 0:00 grep sleep
so it is actually possible to see the shared resource. So it should also work on Linux but then it might be fully native.
How it works on windows I can't tell :-)
I would say you don't. At least not with ps -ef | grep sleep
from the host machine.
This might work:
docker run -it --rm --name coolname ubuntu:latest /bin/bash
sleep 2000&
host machine:
docker exec -it coolname ps -ef | grep sleep
on a Mac you can go a step deeper as docker "native" is actually a minimal linux distro. That image is the actual "shared resource". You can get into that image with a command like screen
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
now if you do the following in a terminal:
docker run -it alpine /bin/sh
sleep 424242&
log in to the native image as described above. You will see the sleep command something like this will be the result:
linuxkit-025000000001:~# ps -ef|grep sleep
3190 root 0:00 sleep 424242
3193 root 0:00 grep sleep
so it is actually possible to see the shared resource. So it should also work on Linux but then it might be fully native.
How it works on windows I can't tell :-)
edited Nov 11 at 19:38
answered Nov 10 at 23:03
Ivonet
1,150518
1,150518
That returns the pid inside the container. I know how to find that. But there should be a sleep running at the host level. I am looking for that pid
– Jim
Nov 11 at 15:00
Just updated my answer a bit... hope that helps
– Ivonet
Nov 11 at 19:38
On Linux each process is run on the host machine. So there is no need to do the screen to get the pid. So I guess in mac there is only 1 process for docker and all the rest forked processes somehow are hidden and not show up as child processes?
– Jim
Nov 11 at 22:46
add a comment |
That returns the pid inside the container. I know how to find that. But there should be a sleep running at the host level. I am looking for that pid
– Jim
Nov 11 at 15:00
Just updated my answer a bit... hope that helps
– Ivonet
Nov 11 at 19:38
On Linux each process is run on the host machine. So there is no need to do the screen to get the pid. So I guess in mac there is only 1 process for docker and all the rest forked processes somehow are hidden and not show up as child processes?
– Jim
Nov 11 at 22:46
That returns the pid inside the container. I know how to find that. But there should be a sleep running at the host level. I am looking for that pid
– Jim
Nov 11 at 15:00
That returns the pid inside the container. I know how to find that. But there should be a sleep running at the host level. I am looking for that pid
– Jim
Nov 11 at 15:00
Just updated my answer a bit... hope that helps
– Ivonet
Nov 11 at 19:38
Just updated my answer a bit... hope that helps
– Ivonet
Nov 11 at 19:38
On Linux each process is run on the host machine. So there is no need to do the screen to get the pid. So I guess in mac there is only 1 process for docker and all the rest forked processes somehow are hidden and not show up as child processes?
– Jim
Nov 11 at 22:46
On Linux each process is run on the host machine. So there is no need to do the screen to get the pid. So I guess in mac there is only 1 process for docker and all the rest forked processes somehow are hidden and not show up as child processes?
– Jim
Nov 11 at 22:46
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241687%2fhow-can-i-see-the-real-process-inside-the-container-in-my-host-machine%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
There's a virtual machine: a key part of "Docker containers share the host's kernel" is that there must be an actual Linux kernel in the stack somewhere.
– David Maze
Nov 10 at 19:36