编程知识 cdmana.com

Docker container is a process. How fresh is it?

Everyone to Docker Should have more or less understanding of , I believe we all have a rough understanding from these two pictures Docker And container concept

So how can we understand containers more easily Container Well ? To put it bluntly

Container It's a process

For example, we run One mongo Mirror image image

Then we list the running containers with the following command ( The following two commands are equivalent to )

#  Old orders docker ps#  New command docker container ls

I suggest using the new command

If you have any doubts about the above equivalent order , Or wonder how the automatic completion of the command in the action diagram is realized , And why the new command is recommended , Please have a look at Docker Command auto-complete , Before you're familiar with commands , It is suggested to make full use of TAB Key to see what each command means , And then combined with the actual use scenarios , Slowly memorize , That's deep-rooted

We run The following command :

# top  -- Display the running processes of a container ( This is a  TAB  Complete the instructions given )docker container top mongo

As you can see from the above figure ,PID by 2292,command by mongod. Since we say container It's a process , Then we should be in Host You can find it in the library , Execute the following command

ps aux | grep mongod

View the execution results :

rgyb   49927 0.0 0.0 4277516 708 s000 S+ 4:06PM 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn mongod

About mongod Only what we just implemented grep mongod The operation of , There's no such thing as that container, Why is that ?

Careful friends may have found that I use Mac Test done ,Docker Platform It runs on Linux On ( stay Linux There will be no such problems in the operating system , You can try it yourself ). I use Docker for Mac, It's actually using macOS Last special xhyve VM A small one running in ( customized )Alpine Linux, So if you want to see this process , We need to get into Mac This Docker VM

Execute the following order :

docker run -it --rm --privileged --pid=host justincormack/nsenter1

( The explanation will not be expanded here , You can have a look at this one justincormack/nsenter1 image What did you do ,Docker for Windows You can also enter in this way Docker VM)

Here we are ,Container It's a process. It's proof , But old gong, What's the use of this .........

版权声明
本文为[Program ape Owen]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224094617751d.html

Scroll to Top