Delete the image operation of none in docker images

Delete the image operation of none in docker images

Since I usually use the docker build command to generate an image, sometimes due to frequent code updates, a lot of none images will be generated. Recently, I want to clear them out.

So I wrote the following script:

docker ps -a | grep "Exited" | awk '{print $1 }'|xargs docker stop
docker ps -a | grep "Exited" | awk '{print $1 }'|xargs docker rm
docker images|grep none|awk '{print $3 }'|xargs docker rmi

Supplement: Docker deletes all none images or stopped containers

After repeated builds in docker, many none images will remain. The following command deletes all none images in one click.

docker rmi `docker images | grep '<none>' | awk '{print $3}'`

A simpler way

docker rmi `docker images -q -f dangling=true`

or

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

Remove all stopped containers

docker rm $(docker ps -a -q)

The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me.

You may also be interested in:
  • Talk about the issue of replacing docker (shim) with containerd in kubernetes1.20
  • How to keep running after exiting Docker container
  • Docker removes abnormal container operations
  • Goodbye Docker: How to Transform to Containerd in 5 Minutes
  • Docker dynamically exposes ports to containers
  • Implementation of local migration of docker images
  • Solve the problem of docker images disappearing
  • Docker image cannot be deleted Error: No such image: xxxxxx solution
  • How to delete an image in Docker
  • Naming containers and images in Docker

<<:  Abbreviation of HTML DOCTYPE

>>:  js array fill() filling method

Recommend

Universal solution for MySQL failure to start under Windows system

MySQL startup error Before installing MySQL on Wi...

Test and solution for MySQL's large memory usage and high CPU usage

After the changes: innodb_buffer_pool_size=576M -...

WeChat applet custom menu navigation to achieve staircase effect

Design Intentions When developing a page, you oft...

How to collect Nginx logs using Filebeat

Nginx logs can be used to analyze user address lo...

Introduction to fuzzy query method using instr in mysql

Using the internal function instr in MySQL can re...

Enterprise-level installation tutorial using LAMP source code

Table of contents LAMP architecture 1.Lamp Introd...

Summary of knowledge points on using calculated properties in Vue

Computed properties Sometimes we put too much log...

How to deploy code-server using docker

Pull the image # docker pull codercom/code-server...

What are the differences between var let const in JavaScript

Table of contents 1. Repeated declaration 1.1 var...

Detailed explanation of desktop application using Vue3 and Electron

Table of contents Vue CLI builds a Vue project Vu...

MySql sharing of null function usage

Functions about null in MySql IFNULL ISNULL NULLI...

Introduction to html form control disabled attributes readonly VS disabled

There are two ways to disable form submission in ...