1
2

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.

Docker run オプション、ステータス遷移まとめ

Last updated at Posted at 2020-02-24

初めてdocerを使って環境構築をしたので、まとめておこうと思います。

docker run オプションまとめ

docker runコマンドは少しあとで説明があるcreateとstartを同時に行えるコマンド。
基本はこれを使うと思われるが、オプションが多くてよくわからなかったためまとめておこうと思う。
スクリーンショット 2020-02-24 17.31.53.png

dockerのライフサイクル

コンテナのステータスの繊維について全体像を把握した上で、ターミナル上でどのような状態となっているのかをまとめておきます。
IMG_0189.jpg

create(作成)

createはコンテナが作られた状態
今回のコンテナ名は[status-test]としているが、ここは任意のコンテナ名を指定。

docker create --name status-test -it alpine /bin/sh

docker psで起動しているコンテナを確認するが起動はしていない。
スクリーンショット 2020-02-24 16.27.46.png
docker ps -aでみるとコンテナとして追加されていることがわかる。
スクリーンショット 2020-02-24 16.27.55.png

start(開始)

runing状態にする

docker start status-test

docker psで起動していることを確認
スクリーンショット 2020-02-24 16.31.59.png

pause(一時停止)

docker pause status-test

STATUSに(paused)がついている。
スクリーンショット 2020-02-24 16.35.28.png

unpause(再開)

docker unpause status-test

STATUSに(paused)が消えている。
スクリーンショット 2020-02-24 16.39.12.png

exited(停止済)

docker stop status-test

画像のコンテナ名はhello-worldですが、ステータスが変化します。
runでまた開始することができます。
スクリーンショット 2020-02-24 16.45.37.png

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?