0
0

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 1 year has passed since last update.

よく使うDocker関連コマンド

Posted at

概要

開発していて使う機会の多いDockerコマンドの備忘録です。初学者向け。

環境・技術
M1 Mac
Docker 24.0.5
Docker Compose 2.20.2

コマンド

# Dockerfileからイメージをビルド
docker-compose build
# キャッシュを使用しない(オプション)
docker-compose build --no-cache

# 複数コンテナの一括作成/起動
docker-compose up
# イメージを再構築(オプション)
docker-compose up --build

# コンテナ一覧の表示
docker-compose ps

# 既存コンテナでコマンドを実行
docker-compose exec 

# コンテナに入る(コンテ内に入り、shellを起動するコマンド)
docker exec -it <コンテナ名> bash
# 例:webという名前のコンテナに入る場合
docker exec -it web bash

# コンテナの停止(削除はしない)
docker-compose stop

# コンテナの起動
docker-compose start

# コンテナの停止および、upで作成したコンテナ、ネットワーク、ボリューム、イメージの削除
docker-compose down

参考

https://www.kagoya.jp/howto/cloud/container/dockercomposeup/
https://docs.docker.jp/compose/reference/build.html
https://docs.docker.jp/compose/reference/down.html
https://www.wakuwakubank.com/posts/354-docker-command-compose/#index_id1
https://tech.kurojica.com/archives/56621/

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?