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 3 years have passed since last update.

Docker[<none>タグの一括削除]

Last updated at Posted at 2020-10-14

#Dockerのタグを一括削除する!
Dockerを触ってるとこんな感じで不要なimage(noneタグ)がいっぱい溜まりますよね〜

$docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
portfolio_api             latest              9091a77d3e50        3 minutes ago       661MB
<none>                    <none>              bda133c88b3a        3 hours ago         659MB
portfolio_front           latest              206c69e39bc8        5 hours ago         325MB
<none>                    <none>              c9c1cc1f82af        3 days ago          325MB
<none>                    <none>              90b26537b543        3 days ago          659MB
rails_nuxt_docker_front   latest              6a76df1e3e15        8 days ago          652MB
rails_nuxt_docker_api     latest              f81ab2aa1da3        9 days ago          664MB
node                      14.11.0-alpine      b85fc218c00b        4 weeks ago         117MB
ruby                      2.7.1-alpine        b46ea0bc5984        3 months ago        52.3MB
postgres                  12.3-alpine         17150f4321a3        3 months ago        157MB
node                      14.4.0-alpine       3bf5a7d41d77        4 months ago        117MB

こいつらが溜まるとGBが喰われて非常に厄介なのです。

$ docker rmi <IMAGE ID>

でチマチマ消すのも面倒なので一括でnoneタグを取得して削除しましょう!

noneタグのみ抽出

  • $docker images-fオプションをつけると検索フィルターをかけることができます
  • 'dangling=true'でnoneタグ(dangling image)を指定できます
$ docker images -f 'dangling=true'
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
<none>                    <none>              bda133c88b3a        3 hours ago         659MB
<none>                    <none>              c9c1cc1f82af        3 days ago          325MB
<none>                    <none>              90b26537b543        3 days ago          659MB

本題<noneタグ>の一括削除

上記のオプションを$docker rmiにぶち込みましょう!!!

$docker rmi $(docker images -f 'dangling=true')
Deleted: sha256:bda133c88b3a3aca1cdd971ffe23a2bea32295e782d1225b7753151f47c40e3d
Deleted: sha256:99c5e34963f7b0ae63427b9e24b1d66778daeda863c078f46476ea9229f17771
...
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?