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

Implementation of MySQL index-based stress testing

1. Simulate database data 1-1 Create database and...

JavaScript Advanced Programming: Variables and Scope

Table of contents 1. Original value and reference...

User experience of portal website redesign

<br />From the launch of NetEase's new h...

A brief discussion on VUE uni-app custom components

1. Parent components can pass data to child compo...

Detailed explanation of how Nginx works

How Nginx works Nginx consists of a core and modu...

HTML background color gradient effect achieved through CSS style

Effect screenshots: Implementation code: Copy code...

jQuery implements nested tab function

This article example shares the specific code of ...

Detailed steps to install Mysql5.7.19 using yum on Centos7

There is no mysql by default in the yum source of...

Detailed explanation of the process of building and running Docker containers

Simply pull the image, create a container and run...

MySQL data types full analysis

Data Type: The basic rules that define what data ...

Detailed explanation of Nginx's control over access volume

Purpose Understand the Nginx ngx_http_limit_conn_...

Implementing a web calculator based on JavaScript

This article shares the specific code of JavaScri...

SSM VUE Axios Detailed Explanation

Table of contents How to display SQL log? ? Descr...

Detailed tutorial on installing harbor private warehouse using docker compose

Overview What is harbor? The English word means: ...