Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How do I get the ID of the Docker container process?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Before we begin

In some cases, for example, if the system load is very high and docker stop cannot close a container (no response), you can find the host process ID based on the ID of the container process, and then kill the container (it is best to use volume data persistence, otherwise there is a risk of data loss in the container).

The procedure lists the current container docker ps-- format'{{.ID}} {{.Names}} 'CONTAINER ID NAMES1201281cb959 web425a6234df74 db to get the container process IDdocker inspect-f' {{State.Pid}} 'web9834 process information tail / proc/9834/cmdline; echo nginx: master process nginx-g daemon off; can also use the topsubcommand docker top web to kill the process ID if necessary, which is equivalent to forcing the container to be closed. Kill-9 9834Docker Container process

The content is extracted from

The relationship between Image and Container is like classes and instances in object-oriented programming. Mirrors are static definitions and containers are entities that mirror runtime. Containers can be created, started, stopped, deleted, paused, and so on.

A container is essentially a process, but unlike a process executed directly in the host, the container process runs in its own independent namespace. So the container can have its own root file system, its own network configuration, its own process space, and even its own user ID space.

Processes in the container run in an isolated environment and are used as if they were operating on a system independent of the host. This feature makes container-encapsulated applications more secure than running directly in the host.

Summary

Finally, let's summarize the knowledge points in the article.

The Docker container is essentially a process on the host. The container process ID is the host process ID because they are the same. If the Docker daemon responds normally, do not kill the process directly.

Reference article

Doker&k8s Qun [703906133]

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report