4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

コンテナからプロセスID(pid)を確認する

Last updated at Posted at 2019-07-11

docker inspect [container ID]で確認できる。

検証

  1. コンテナを二つ立ち上げる
$ docker run --name alpine_test -itd alpine
148c39d151fab8861c2527a15b13d1a613f9bfa02b0a8b1284b64e82f9f2dff2
$ docker run --name alpine_test_2 -itd alpine
e7f8a6a77b2a03928b68e3256c75f01a45b058ffadeaa243aef9a70dc12a1381
$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
148c39d151fa        alpine              "/bin/sh"           3 seconds ago       Up 1 second                             alpine_test
40e81cafeafd        alpine              "/bin/sh"           About an hour ago   Up About an hour                        alpine_test_2
  1. 立ち上げたコンテナのプロセスIDを確認する
ps aux | grep "/bin/sh"
PID   USER     TIME  COMMAND
  216 root      0:00 /bin/sh
  406 root      0:00 /bin/sh
  526 root      0:00 grep bin/sh

216, 406のプロセスがどのコンテナに割り当たっているのか、プロセスIDだけ見ても分からない。

  1. コンテナの情報を取得する
$ docker inspect alpine_test | grep Pid
            "Pid": 406,
            "PidMode": "",
            "PidsLimit": 0,

Pidが、プロセスID。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?