30
30

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 2014-12-12

http://www.calazan.com/docker-cleanup-commands/
上記サイトで紹介されているコマンドをよく使うので、日本語訳、しようかと思ったのですが、コマンドだけコピペで。

Dockerコマンドメモ
こちらのメモにもお世話になってます。

Kill all running containers
docker kill $(docker ps -q)

Delete all stopped containers (including data-only containers)
docker rm $(docker ps -a -q)

Delete all ‘untagged/dangling’ () images
docker rmi $(docker images -q -f dangling=true)

Delete ALL images
docker rmi $(docker images -q)

任意のレポジトリのイメージを全部削除したい場合(誤って他のも消しちゃうかもなので、grep注意
docker rmi $(docker images | grep 'REPOSITORY_NAME' | awk '{print$3}')

古いコンテナを削除したい場合(-fオプションがついているため実行中のContainerも削除されます。停止しているContainerのみ削除したい場合は-fを取り除いて下さい。

  • 数週間前
    • docker ps -a | grep 'weeks ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm -f
  • 1週間前
    • docker ps -a | grep 'week ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm -f
  • 数日前
    • docker ps -a | grep 'days ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm -f
  • 1日前
    • docker ps -a | grep 'day ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm -f
  • 数時間前
    • docker ps -a | grep 'hours ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm -f
  • 1時間前
    • docker ps -a | grep 'hour ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm -f
  • 数分前
    • docker ps -a | grep 'minutes ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm -f
  • 1分前
    • docker ps -a | grep 'minute ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm -f
  • 数秒前
    • docker ps -a | grep 'seconds ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm -f

適宜自分用に更新します。。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?