139
112

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で不要なコンテナとイメージを削除する

Last updated at Posted at 2016-09-05

メモ

# 停止中コンテナの削除(起動中のコンテナはrmがエラーになるので細かいことを気にしなければこれで問題ない)
#docker rm $(docker ps -a -q)

# 停止中コンテナの削除(少し丁寧版?停止中のコンテナのみを削除)
docker rm $(docker ps -f status=exited -f status=created -f status=dead -f status=paused -q)


# 不要なイメージの削除(REPOSITORYが<none>の奴)
docker rmi $(docker images -f dangling=true -q)

# 最近のバージョンでは↓これでOK
docker system prune -a

今は prune で簡単にできる

# 停止中のコンテナや未使用ボリュームやイメージやネットワークを全部削除する
docker system prune -f

# 個別に削除したい場合は以下のようにすればOK
docker container prune -f
docker volume prune -f
docker network prune -f
docker image prune -f
139
112
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
139
112

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?