0
1

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, Docker-compose 良く使うコマンド

Posted at

docker, Docker-compose 良く使うコマンド

Dockerを使う際に良くコマンドを忘れてしまうので、
自分用の忘備録です。

Docker-compose build

docker-compose build

imageを作成・Pullするコマンド、

docker-compose run

docker-compose run (サービス名) (コマンド)
example: docker-compose run --rm app bash 

コンテナを起動して、コマンドを実行することができる。
-rm を追加することによって、コマンドを実行した後に、
コンテナを削除します。

docker-compose up する前などに、一時的にコンテナ内に入り
コマンドを実行したい時などに便利です。

docker-compose exec

docker-compose exec (サービス名) (コマンド名)
example: docker-compose exec app bash

これは、稼働中のコンテナに入りコマンドを実行するための物です。

docker-compose run

docker-compose up

このコマンドを実行すると、
docker-compose.ymlで記述した通りにコンテナを作成し、
コンテナ同士を繋げて起動をします。

-d をオプションとしてつけることで、バックグラウンドでコンテナを起動します。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?