Start cleaning carefully! List unused volumes
Clean up unused volumes
Clean up useless images
Continue cleaning
The above are enough for use, don’t know other commands! Additional knowledge: Docker article teaches you how to clean up Docker space to free up disk space How to clean up the docker directory The docker directory has filled up the system disk and is difficult to migrate. I want to ask if there is a quick solution. The answer is yes. The following are classic cases I have compiled, which are suitable for production and testing. Write a script to clean up the docker log as follows: [root@www ~]# cat clean_docker_log_space.log #!/bin/bash docker_log_files=$(find /var/lib/docker/containers/ -name '*-json.log') docker_logs_size=$(find /var/lib/docker/containers/ -name '*-json.log' | xargs du -sc | tail -1 |awk '{print $1,"K"}') free -h && sync && echo 1 > /proc/sys/vm/drop_caches #Release system cache echo -e "\033[32mThe docker log total size is $docker_logs_size\033[0m" for log in $docker_log_files do echo "Now is cleaning docker log,docker core logs:$log" cat /dev/null > $log systemctl reload docker #Reload the docker service without affecting existing docker done free -h The results are as follows: [root@www ~]# ./clean_docker_log_space.log total used free shared buff/cache available Mem: 976M 598M 112M 6.8M 264M 157M Swap: 511M 66M 445M The docker log total size is 80 K Now is cleaning docker log,docker core logs:/var/lib/docker/containers/7538f077348e3c9722fb90ed4b0a5c3d60d72112e989526767c63d55f5a76f3e/7538f077348e3c9722fb90ed4b0a5c3d60d72112e989526767c63d55f5a76f3e-json.log Now is cleaning docker log,docker core logs:/var/lib/docker/containers/235d20190027e757a203f1b4d4093335fb92ba515f7a501448c36c1332c622a2/235d20190027e757a203f1b4d4093335fb92ba515f7a501448c36c1332c622a2-json.log Now is cleaning docker log,docker core logs:/var/lib/docker/containers/685a7af447ce884de1e9bbeb5d4ca0ca99860096f71c33b4f9a4d15a427c5e00/685a7af447ce884de1e9bbeb5d4ca0ca99860096f71c33b4f9a4d15a427c5e00-json.log total used free shared buff/cache available Mem: 976M 599M 176M 6.8M 200M 168M Swap: 511M 66M 445M [root@www ~]# find /var/lib/docker/containers/ -name '*-json.log' | xargs du -sc | tail -1 |awk '{print $1,"K"}' 0K It is recommended to add the script to the Linux scheduled task and clean it up once a week. This can ensure that Docker does not generate additional log files. The production environment is as follows df -TH docker uses 93% of the system disk Execute the script clean_docker_log_space.log. After executing the cleanup script, df -TH shows that docker uses 43% of the system disk. Docker deployment suggestions Finally, it is recommended that you deploy docker applications in the docker custom configuration directory #First, mount the disk with the required capacity and select /data as the mount directory [root@www ~]# mkdir -p /data #Stop Docker [root@www ~]# systemctl stop docker #Move data to a new directory [root@www ~]# mv /var/lib/docker /data #Modify configuration, add --graph /data [root@www ~]# vim /usr/lib/systemd/system/docker.service ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --graph /data [root@www ~]# systemctl daemon-reload [root@www ~]# systemctl start docker [root@www ~]# systemctl enable docker.service Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. The above Docker environment cleaning operation is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Solve the scroll-view line break problem of WeChat applet
>>: SQL Optimization Tutorial: IN and RANGE Queries
During project development, our database data is ...
Table of contents 1. Start and stop service instr...
Method 1: Please add the following code after <...
Table of contents 1. Eclipse configures Tomcat 2....
Example: We use the Python code loop_hello.py as ...
Nowadays we often talk about Web2.0, so what is W...
Table of contents 01 Problem Description 02 Solut...
Arrow function is a new feature in ES6. It does n...
This article shares the specific code of vue+echa...
Preface Some people have asked me some MySQL note...
Table of contents The node version does not corre...
Table of contents 1. Introduction 2. The first me...
Preface I recently encountered some problems at w...
1. What is master-slave replication? Master-slave...
This article records the installation tutorial of...