Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@Terry3

dockerのrestart→exec→exitではexitedしない話

dockerを勉強し始めて、exitしたのにexitedにならなくハマったお話。

開始前のコンテナの状態

$docker ps -aでコンテナの状況を確認。

$docker ps -a 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                        PORTS               NAMES
b45e56cec3c6        ubuntu              "bash"              7 hours ago         Exited (137) 17 minutes ago                       silly_hoover
c71eae7ff038        hello-world         "/hello"            7 hours ago         Exited (0) 7 hours ago                            elegant_swanson
6374f67a1248        hello-world         "/hello"            7 hours ago         Exited (0) 7 hours ago                            epic_varahamihira

今回はCONTAINER ID:b45e56cec3c6を起動する。

コンテナ起動

$docker restart b45e56cec3c6で起動してみる。

$docker ps -a               
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                   PORTS               NAMES
b45e56cec3c6        ubuntu              "bash"              7 hours ago         Up 1 second                                  silly_hoover
c71eae7ff038        hello-world         "/hello"            7 hours ago         Exited (0) 7 hours ago                       elegant_swanson
6374f67a1248        hello-world         "/hello"            7 hours ago         Exited (0) 7 hours ago                       epic_varahamihira

起動した。

ubuntuの中へ

$docker exec -it b45e56cec3c6 bashでbash実行。

$docker exec -it b45e56cec3c6 bash  
root@b45e56cec3c6:/# 

入った。

コンテナを抜ける

$exitでコンテナを抜けホストに戻る。

root@b45e56cec3c6:/# exit
exit

戻ってきたので、コンテナのステータスを確認。

ステータス

$docker ps -aで確認

$docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                   PORTS               NAMES
b45e56cec3c6        ubuntu              "bash"              7 hours ago         Up 4 minutes                                 silly_hoover
c71eae7ff038        hello-world         "/hello"            7 hours ago         Exited (0) 7 hours ago                       elegant_swanson
6374f67a1248        hello-world         "/hello"            7 hours ago         Exited (0) 7 hours ago                       epic_varahamihira

exitedになっていない。。。

アタッチしてみる

$docker attach b45e56cec3c6

docker attach b45e56cec3c6
root@b45e56cec3c6:/# 

入れた。

再度exit

$exitを再度実行。

$exit
exit

再度ステータスを確認

$docker ps -aを再度実行。

$docker ps -a                     
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
b45e56cec3c6        ubuntu              "bash"              7 hours ago         Exited (0) 41 seconds ago                       silly_hoover
c71eae7ff038        hello-world         "/hello"            7 hours ago         Exited (0) 7 hours ago                          elegant_swanson
6374f67a1248        hello-world         "/hello"            7 hours ago         Exited (0) 7 hours ago                          epic_varahamihira

無事exitedになってる!

0
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Terry3

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?