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?










share|improve this question





















  • 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














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?










share|improve this question





















  • 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












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?










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 17:40









Jim

29117




29117











  • 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




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












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 :-)






share|improve this answer






















  • 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










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















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

























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 :-)






share|improve this answer






















  • 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














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 :-)






share|improve this answer






















  • 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












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 :-)






share|improve this answer














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 :-)







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 11 at 19:38

























answered Nov 10 at 23:03









Ivonet

1,177518




1,177518











  • 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










  • 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

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo