LoginSignup
3
6

More than 5 years have passed since last update.

docker-compose コマンドメモ

Last updated at Posted at 2017-09-07

docker-compose コマンドメモ

docker-compose で開発を行うことになったのでコマンドまとめ

用語

  • docker-compose.yml : docker-compose の設定ファイル

コマンド - 見る系

ps

コンテナ一覧の表示(存在確認)

$ docker-compose ps

# 停止時
   Name        Command      State     Ports
-------------------------------------------
sample-container   /sbin/init   Exit 137

# 起動時
   Name        Command     State           Ports
--------------------------------------------------------
sample-container   /sbin/init   Up      0.0.0.0:8443->443/tcp

top

コンテナのプロセス情報の表示(起動確認)

$ docker-compose top

sample-container
PID    USER   TIME             COMMAND
-------------------------------------------------
1908   root   0:00   /sbin/init
2041   root   0:00   /sbin/udevd -d
2395   root   0:00   /sbin/mingetty /dev/tty[1-6]

コマンド - 起動 - 停止

start

サービスの起動

# 起動前の停止確認
$ docker-compose ps

   Name        Command      State     Ports
-------------------------------------------
sample-container   /sbin/init   Exit 137

$ docker-compose top

# 起動
$ docker-compose start
Starting sample-container ... done

# 起動確認
$ docker-compose ps

   Name        Command     State           Ports
--------------------------------------------------------
sample-container   /sbin/init   Up      0.0.0.0:8443->443/tcp

$ docker-compose top

sample-container
PID    USER   TIME             COMMAND
-------------------------------------------------
2575   root   0:00   /sbin/init
2692   root   0:00   /sbin/udevd -d
2968   root   0:00   /sbin/mingetty /dev/tty[1-6]

stop

サービスの停止
```shell

停止

$ docker-compose stop
Stopping sample-container ... done

停止確認

$ docker-compose ps

Name Command State Ports

sample-container /sbin/init Exit 137

$ docker-compose top


## コマンド - 作る - 消す

### up

コンテナの作成 + 起動

```shell
# 作成前のコンテナ確認
$ docker-compose ps

Name   Command   State   Ports
------------------------------

$ docker-compose top

# 作成
$ docker-compose up -d # コンテナの作成 + 起動 -d:バックグラウンド実行
Creating sample-container ...
Creating sample-container ... done

# コンテナ確認
$ docker-compose ps

   Name        Command     State           Ports
--------------------------------------------------------
sample-container   /sbin/init   Up      0.0.0.0:8443->443/tcp

$ docker-compose top

sample-container
PID    USER   TIME             COMMAND
-------------------------------------------------
3172   root   0:00   /sbin/init
3287   root   0:00   /sbin/udevd -d
3559   root   0:00   /sbin/mingetty /dev/tty[1-6]

down

コンテナの削除

# コンテナ削除
$ docker-compose down

Stopping sample-container ... done
Removing sample-container ... done
Removing network docker_default

$ docker-compose ps

Name   Command   State   Ports
------------------------------

$ docker-compose top

docker-compose.yml の設定反映

$ docker-compose down
$ docker-compose up -d

参考URL

3
6
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
3
6