LoginSignup
1
2

More than 3 years have passed since last update.

Dockerの溜まったゴミを消す

Last updated at Posted at 2019-12-06

開発環境でdocker builddocker runを繰り返していると、色々なゴミが溜まってPCのリソースを圧迫していきます。
それらの溜まったゴミを一発で消すコマンドです。(※自己責任で)

いらないイメージ(<none>イメージ)を消す

docker image prune -f 

現在起動中のコンテナを全部止めて、全部消す

docker container stop `docker ps -a -q` && docker container prune -f

これはdocker-compose使ってれば、docker-compose downで一発OKなんですが
個別にコンテナ起動してる場合もあると思うので一応

最強の呪文

docker system prune --all -f

このコマンドは

  - all stopped containers
  - all networks not used by at least one container
  - all images without at least one container associated to them
  - all build cache

ってことで徹底的にゴミを消し去ってくれます。
とてもスッキリするので、ぜひ一度お試しあれ

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