If you use docker for large-scale development but don't have a cleanup strategy, your disk will fill up quickly and when you really have to ship something immediately because the product is hot, you won't be able to ship it. When we run a process in a computer, once the process is completed, everything is destroyed. Containers are the infrastructure that many of us operate on today. Everything runs in a container, aiming to have one process per container. When the process is complete, the container exits. But it won't clean up on its own. What Docker has accumulatedYou need to pay attention to these
You may not care too much about disk space if you have enough space, but network is important too. By default, Docker uses the bridge network, which has a limit of 31 networks. When the limit is reached, you will see the following message: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network This can happen if you are a heavy docker-compose user who creates one network per project. You can fix the problem by setting a custom docker network create dada --subnet 192.167.11.0/24 But anyway, the point of this article is cleaning. Clean up with dockerCleaning up stopped containersdocker rm -v $(docker ps --all --quiet --filter 'status=exited') This will find all containers in the exited state and print their IDs one per line so we can feed it to other shell commands. We use Cleaning up disk volumesThe above command should remove the volume associated with this container. If you created volumes manually and want to delete any unused volumes: docker volume rm $(docker volume ls --quiet --filter 'dangling=true') Clean up the imageIt is usually safe to remove all Docker images. We can get it on demand when we need it. Usually after an image is cleaned, build times will be longer because the Docker daemon needs to spend time downloading the image again. docker rm --force $(docker images --quiet) Here, we use Cleaning up the networkIt's very simple. We can delete any network and it will be recreated later on demand. docker network rm $(docker network ls --quiet) Clean up with docker-composeIf you use docker-compose to start your containers, we have an easy way to clean up the resources associated with a specific compose file. docker-compose down --volumes --rmi all --remove-orphans Unfortunately, this command does not remove anonymous volumes, so you will have to deal with those. One command solves all problemsDocker is ephemeral, we can always re-obtain our image, re-create our database for development, or if this is just a continuous integration system, we can delete everything. docker system prune --all --force --volumes This concludes this article on common methods and issues of Docker cleanup. For more Docker cleanup content, please search 123WORDPRESS.COM’s previous articles or continue browsing the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Analyze the difference between querySelector and getElementById methods in JavaScript
>>: Eight rules for effective web forms
Special note: Only the Swoole extension is instal...
Table of contents Safe Mode Settings test 1. Upda...
Table of contents Linux-Use MyCat to implement My...
Table of contents need Core Idea Two ways to impl...
1. Add skip-grant-tables to the my.ini file and r...
1. Introduction Recently I found that there are m...
Test environment: C:\>systeminfo | findstr /c:...
Cause: NVIDIA graphics card driver is damaged Sol...
Result:Implementation Code html <link href=...
In MySQL, how do you view the permissions a user ...
Table of contents Preface text 1. Install styleli...
To achieve this effect, you must first know a pro...
0. Introduction August 18, 2016 Today, I noticed ...
http://www.cppcns.com/shujuku/mysql/283231.html Y...
When multiple images are introduced into a page, ...