0
3

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 | docker image を ダウンロードする / 削除する

Last updated at Posted at 2016-11-21

イメージのダウンロード

実行

docker pull する。

$ docker pull hello-world

確認

イメージの一覧を見ると、ダウンロードされているのが分かる。

$ docker images | grep hello

hello-world         latest              c54a2cc56cbb        4 months ago        1.848 kB

イメージの削除

実行

イメージ名を指定して docker rmi ( remove image ) する。

$ docker rmi hello-world

確認

イメージが削除されているのが分かる。

$ docker images | grep hello

イメージの削除に失敗する時

「コンテナ」が「イメージ」を使っていて消せない場合。

$ docker rmi hello-world
Error response from daemon: conflict: unable to remove repository reference "hello-world" (must force) - container 6588acea9641 is using its referenced image c54a2cc56cbb

原因

$ docker run hello-world

でコンテナを立ち上げているせい。

コンテナの状態を確認する

docker ps で確認すると、コンテナ ( 6588acea9641 ) が イメージ ( hello-world ) を使っているっぽい。

$ docker ps -as | grep hello-world
6588acea9641        hello-world         "/hello"            About a minute ago   Exited (0) About a minute ago                       drunk_kowalevski    0 B (virtual 1.848 kB)

コンテナを殺す

docker rm で該当のコンテナを殺す。

$ docker rm 6588acea9641
6588acea9641

再度イメージの削除を実行する

無事f成功した。

$ docker rmi hello-world
Untagged: hello-world:latest
Untagged: hello-world@sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Deleted: sha256:c54a2cc56cbb2f04003c1cd4507e118af7c0d340fe7e2720f70976c4b75237dc
Deleted: sha256:a02596fdd012f22b03af6ad7d11fa590c57507558357b079c3e8cebceb4262d7

環境

  • Docker version 1.12.3, build 6b644ec
  • Docker for mac

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?