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コマンド 〜イメージ操作〜

個人的によく使うDockerコマンドをまとめてみた

1. イメージの一覧表示

docker image ls
docker image ls
  • サンプル
    • docker image ls -a
  • オプション
    • -a: 全てのイメージを表示

2. イメージのPull

docker image pull
docker image pull --platform {プラットフォーム} {コンテナイメージ名}:{タグ}
  • サンプル
    • docker image pull --platform linux/amd64 centos:7
  • オプション
    • --platform: マルチプラットフォームに対応している場合は指定("linux/amd64", "linux/arm64/v8")

3. イメージの削除

docker image rm
docker image rm {コンテナイメージ名}:{タグ}
  • サンプル
    • docker image rm centos:7
  • オプション
    • -f: 強制的に削除する

4. イメージのファイル出力

docker image save
docker image save {コンテナイメージ名}:{タグ} -o {保存先ファイル名.tar}
  • サンプル
    • docker image save centos:7 -o centos_7.tar
    • docker image save centos:7 | gzip > centos_7.tgz
  • オプション
    • -o: ファイル出力させる(デフォルトはtarファイルで出力)
  • 補足
    • 「 | gzip > 」を使うと圧縮ファイルとして出力できる

5. イメージファイルからの読み込み

docker image load
docker image load -i {読み込み先ファイル名.tar}
  • サンプル
    • docker image load -i centos_7.tar
  • オプション
    • -i: イメージファイル(.tar .tgz)からの読み込み先ファイルを指定する

6. イメージの履歴表示

docker image history
docker image history {コンテナイメージ名}:{タグ}
  • サンプル
    • docker image history centos:7
  • 補足
    • レイヤ毎のサイズや、作成した日付が確認できる

7. イメージの詳細情報の確認

docker image inspect
docker image inspect {コンテナイメージ名}:{タグ}
  • サンプル
    • docker image inspect centos:7

参考

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?