How to delete untagged images in bulk with Docker

Introduction

When using docker, the image may take up space. It is troublesome to delete them one by one, so make a note of the command to delete untagged images at once. I will also summarize the meaning of command options.

Batch delete untagged images command

docker rmi $(docker images -f "dangling=true" -q)

You can delete untagged images in bulk by running the above command.

Command description

Get untagged image by setting dangling to true with filter option

docker images -f "dangling=true"
#Execution result
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              c29504d0f8fd        2 weeks ago         1.21GB
<none>              <none>              e6325cdc18c4        2 weeks ago         1.18GB

Get ID only with quiet option

docker images -f "dangling=true" -q
#Execution result
c29504d0f8fd
e6325cdc18c4

Delete image using the obtained ID

docker rmi $(docker images -f "dangling=true" -q)

Please refer to the official document for details.

Official documentation

Docker docs|docker images https://docs.docker.com/engine/reference/commandline/images/ Docker docs|docker rmi https://docs.docker.com/engine/reference/commandline/rmi/

Recommended Posts

How to delete untagged images in bulk with Docker
How to call functions in bulk with Java reflection
How to start Camunda with Docker
How to share files with Docker Toolbox
One liner to delete all Docker images
[Rails] How to use rails console with docker
How to switch thumbnail images with JavaScript
How to use Docker in VSCode DevContainer
How to run a job with docker login in AWS batch
How to delete data with foreign key
Understand in 5 minutes !! How to use Docker
How to run Blazor (C #) with Docker
How to build Rails 6 environment with Docker
How to execute with commands of normal development language in Docker development environment
How to start a Docker container with a volume mounted in a batch file
How to check the logs in the Docker container
How to update pre-built files in docker container
How to give your image to someone with docker
How to use docker compose with NVIDIA Jetson
How to use nginx-ingress-controller with Docker for Mac
[Rails] How to build an environment with Docker
How to install Docker
Delete all Docker images
How to implement UICollectionView in Swift with code only
How to sort in ascending / descending order with SQLite
How to switch Tomcat context.xml with WTP in Eclipse
How to build docker environment with Gradle for intelliJ
How to delete a new_record object built with Rails
How to use Z3 library in Scala with Eclipse
[Docker environment] How to deal with ActiveSupport :: MessageEncryptor :: InvalidMessage
Organized how to interact with the JDK in stages
[How to insert a video in haml with Rails]
How to use JDD library in Scala with Eclipse
How to make Laravel faster with Docker for Mac
How to query Array in jsonb with Rails + postgres
[Docker + Rails] How to deal with Rails server startup failure
How to launch Swagger UI and Swagger Editor in Docker
How to delete BOM (UTF-8)
[rails] How to post images
How to handle uploaded images
How to minimize Java images
How to set Docker nginx
How to number (number) with html.erb
How to update with activerecord-import
Let's write how to make API with SpringBoot + Docker from 0
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Express ~
How to get values in real time with TextWatcher (Android)
How to get started with Gatsby (TypeScript) x Netlify x Docker
[Rails] How to delete images uploaded by carrierwave (using devise)
How to build Rails, Postgres, ElasticSearch development environment with Docker
How to use mysql with M1 mac Docker preview version
Mapping to a class with a value object in How to MyBatis
[Docker context] ~ How to access docker in remote environment from VScode ~
How to set up a proxy with authentication in Feign
Write DiscordBot to Spreadsheets Write in Ruby and run with Docker
How to scroll horizontally with ScrollView
How to find May'n in XPath
How to hide scrollbars in WebView
How to get started with slim
How to run JUnit in Eclipse
How to deal with 405 Method Not Allowed error in Tomcat + JSP