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

Reasons and solutions for not being able to detect array changes in Vue2

Table of contents Workaround Why can't I moni...

Implementation of LNMP for separate deployment of Docker containers

1. Environmental Preparation The IP address of ea...

Essential skills for designing web front-end interfaces

[Required] UserInterface PhotoShop/Fireworks Desi...

Vue+element implements drop-down menu with local search function example

need: The backend returns an array object, which ...

MySQL method steps to determine whether it is a subset

Table of contents 1. Problem 2. Solution Option 1...

Detailed explanation of CSS background and border tag examples

1. CSS background tag 1. Set the background color...

MySql 5.7.21 free installation version configuration method under win10

1. Unzip to the location where you want to instal...

How to purchase and install Alibaba Cloud servers

1. Purchase a server In the example, the server p...

Three Ways to Lock and Unlock User Accounts in Linux

If you already have some kind of password policy ...

5 solutions to CSS box collapse

First, what is box collapse? Elements that should...

Record the steps of using mqtt server to realize instant communication in vue

MQTT Protocol MQTT (Message Queuing Telemetry Tra...

js to implement a simple bullet screen system

This article shares the specific code of native j...

Steps to install cuda10.1 on Ubuntu 20.04 (graphic tutorial)

Pre-installation preparation The main purpose of ...

Six weird and useful things about JavaScript

Table of contents 1. Deconstruction Tips 2. Digit...