Weird and interesting Docker commands you may not know

Weird and interesting Docker commands you may not know

Intro

Introduces and collects some simple and practical docker commands that may be used but few people use them

dangling images

When building your own docker image, you may encounter the situation of using one or more intermediate images. This will reduce the size of the final packaged docker image to a certain extent, but will also generate some useless images with the tag none, also known as dangling images.

List all dangling images:

docker images -f "dangling=true"

Remove all dangling images:

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

Batch Operations

When the server is restarted or shut down for some reason, all Docker containers may need to be restarted. Start all Docker containers

Note: If there are dependencies, such as link, etc., you should start these dependent containers first

docker start $(docker ps -aq)

Stop all docker containers

docker stop $(docker ps -aq)

Delete all docker containers

docker rm $(docker ps -aq)

Delete all docker images

docker rmi $(docker images -q)

Docker resource cleanup

docker container prune # Delete all exited containers docker volume prune # Delete unused data volumes docker image prune # Delete dangling or all unused images docker system prune # Delete stopped containers, dangling images, networks not referenced by containers, and caches during the build process
# For safety reasons, this command will not delete data volumes that are not referenced by any container by default. If you need to delete these data volumes at the same time, you need to explicitly specify the --volumns parameter docker system prune --all --force --volumns # This time, not only will the data volumes be deleted, but there will be no confirmation process! Note that using the --all parameter will delete all unreferenced images, not just dangling images.

Reference

https://www.jb51.net/article/143173.htm

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of the construction and use of Docker private warehouse
  • Docker Stack deployment method steps for web cluster
  • Example of how to quickly build a LEMP environment with Docker
  • Detailed explanation of log processing of Docker containers
  • Docker creates MySQL explanation
  • Solution to the error when installing Docker on CentOS version
  • Using Docker to create static website applications (multiple ways)
  • How to deploy microservices using Spring Boot and Docker
  • How to install Docker on Raspberry Pi
  • Docker containers communicate directly through routing to achieve network communication

<<:  Solution to the problem of repeated triggering of functions in Vue project watch

>>:  How to solve the error "ERROR 1045 (28000)" when logging in to MySQL

Recommend

Detailed explanation of CSS3 text shadow text-shadow property

Text shadow text-shadow property effects: 1. Lowe...

Use Docker to build a Redis master-slave replication cluster

In a cluster with master-slave replication mode, ...

Some tips for using less in Vue projects

Table of contents Preface 1. Style penetration 1....

The use of MySQL triggers and what to pay attention to

Table of contents About Triggers Use of triggers ...

Eclipse configures Tomcat and Tomcat has invalid port solution

Table of contents 1. Eclipse configures Tomcat 2....

Rhit efficient visualization Nginx log viewing tool

Table of contents Introduction Install Display Fi...

harborRestart operation after modifying the configuration file

I won't say much nonsense, let's just loo...

js to achieve floor scrolling effect

This article uses jQuery to implement the sliding...

How to set mysql to case insensitive

mysql set to case insensitive Windows Go to the d...

js array entries() Get iteration method

Table of contents 1. Detailed syntax of entires()...

Pure CSS3 to achieve mouse over button animation Part 2

After the previous two chapters, do you have a ne...

Vue implements image drag and drop function

This article example shares the specific code of ...