This article is a mirror article of machine translation, please click here to jump to the original article.

View: 8653|Reply: 6

Docker logs fill up disks and data migration

[Copy link]
Posted on 2/7/2022 10:21:43 AM | | | |
The colleague reacted that the system could not log in to the test environment, decisively checked the monitoring, and found that the service port was open, and logged in to the server to check the hard disk usage and found that the directory mounted on a certain disk was full, as shown in the figure below:



The disk is 100% the disk used by the docker application, and it is initially suspected that the inability to write log files prevents the module from providing services to the outside world.

CentOS counts each folder size and looks for large files
https://www.itsvse.com/thread-9542-1-1.html
Look for large files and finally locate them under the /var/lib/docker/containers/ subdirectoryA certain json.log file is taking up 30G

Cleaning Running Container Logs (Symptom Treatment)

In order to allow the container to serve normally immediately. Temporary solution, quickly clean up such files, free up hard disk space, the script is as follows:

If the docker container is running, then after deleting the logs using rm -rf, you will find that disk space is not freed up via df -h. The reason is that on Linux or Unix systems, deleting a file via rm -rf or a file manager will unlink it from the directory structure of the file system. If the file is opened (and there is a process in use), the process will still be able to read the file and disk space will be taken up all the time. The correct pose is cat /dev/null > *-json.log, and of course you can also restart docker after removing it via rm -rf.

Remark:Create a new script in the directory of the free disk, otherwise the script cannot be created normally


Setting the Docker Container Log Size (Root Cause)

Set the maximum log size of a container service, and add a parameter to set the log size of the container when starting the container, for example:

max-size=500m, which means that the upper limit of the log size of a container is 500M,
max-file=3, which means that a container has three logs, namely id+.json, id+1.json, and id+2.json.


Docker migrated to a new disk

docker-related data exists on the system disk, the system disk is only 50G in size, and the data disk is 100G in size, how to move the existing data of docker to the data disk?

For docker installed using the CentOS system yum method, the default installation directory should be: /var/lib/docker

Docker version < v17.05.0

Because dockerd can specify the image and container storage path through the parameter graph, such as –graph=/var/lib/docker, we only need to modify the configuration file to specify the startup parameters.

Docker's configuration file can set most of the background process parameters, and the storage location in each operating system is inconsistent, in Ubuntu: /etc/default/docker, and in CentOS: /etc/sysconfig/docker.

Docker version >= v17.05.0

Because Docker officially deprecated the graph feature in this release, if you have Docker version >= v17.05.0 installed on your machine, you cannot modify the default installation (storage) directory of Docker by specifying the graph parameter in the /etc/default/docker configuration file.

There are other ways in which the new version of Docker can achieve our goal of modifying the installation (storage) directory: by modifying (new) /etc/docker/daemon.json to specify the value of the data-root parameter.

Docker daemon directory configuration:The hyperlink login is visible.

Migration preparation: Stop all container applications and stop docker services (systemctl stop docker).


Docker looks at container restart settings and bulk stop containers
https://www.itsvse.com/thread-10130-1-1.html
Create a new directory in /home/software with the following command:

Migrate the /var/lib/docker directory to the /home/software/docker directory (it is recommended to copy it, and then delete the /var/lib/docker directory file when it is fine), the command is as follows:

When copyingBe sure to add the -a parameter, otherwise some containers will not work properly!!!!!

View all soft connections and file points in the current directory with the following command:


Modify the /etc/docker/daemon.json file with the following command:



Save, then start the docker service with the following command:

Start the container, the tests are all running normally, and finally,Delete the /var/lib/docker folder



(End)




Previous:Check the Linux system turn-on and shutdown times
Next:Filter factories built into Spring Cloud Gateway
Posted on 2/13/2022 4:36:29 PM |
Learn to learn。。。。。
 Landlord| Posted on 2/24/2022 9:38:26 AM |
docker how to remove a none image
https://www.itsvse.com/thread-10112-1-1.html
 Landlord| Posted on 2/24/2022 1:21:48 PM |
List
description
CONTAINER ID and NameThe ID and name of the container
CPU % and MEM %The percentage of host CPU and memory that the container is using
MEM USAGE / LIMITThe total memory that the container is using, and the total amount of memory allowed to be used
NET I/OThe amount of data that a container sends and receives through its network interface
BLOCK I/OThe amount of data that a container reads and writes from a block device on the host
PIDsThe number of processes or threads created by the container


 Landlord| Posted on 3/25/2022 2:45:13 PM |
You can find the corresponding container application by querying the Name value of the /var/lib/docker/containers/xxxx/config.v2.json file.



Posted on 12/7/2022 2:17:31 PM |
Docker logs fill up disks and data migration
 Landlord| Posted on 4/17/2023 9:59:49 AM |
docker empties the logs of a container individually with the following command:

Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com