Get the App
SLTechnology News&Howtos  ›  Development  › 

How to migrate the / var/lib/docker directory of docker

Shulou Source: shulou.com Published: 2022-06-03 20:00:17 09月20日 Update

This article introduces the relevant knowledge of "how to migrate the docker / var/lib/docker directory". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Since I came to the company in the morning and found that / var/lib/docker/overlay2 takes up a lot of space, I decided to do some work on / var/lib/docker directory migration.

1. First, you need to stop the docker service.

Systemctl stop docker.service

two。 Use the command df-h to take a look at the disk and find a large space.

3. Create a new directory for docker. I found data here, so the new directory address on my side is / data/docker/lib/.

Mkdir-p / data/docker/lib

Note: the parameter-p ensures that the directory name exists, and if the directory does not exist, create a new one.

4. Start the migration

Rsync-avzP / var/lib/docker / data/docker/lib/

First confirm whether rsync is installed.

Parameter explanation:

-a, the archive mode, represents a recursive transfer and maintains file attributes.

-v to display the details of the rsync process. You can use "- vvvv" to get more details.

-P, displays the progress information of the file transfer. In fact, "- P" = "--partial-- progress", where "--progress" is the one that displays the progress information.

-z, compression during transmission to improve efficiency.

5. Specify a new docker directory

Vim / lib/systemd/system/docker.service

Join in ExecStart:

-- graph=/data/docker/lib/docker

6. Restart docker

Systemctl daemon-reload systemctl restart docker systemctl enable docker

7. Confirm that there is no problem with docker after startup, and delete the old / var/lib/docker/ directory

The work of migrating the docker directory here is over, so be sure to choose the working directory first when installing docker.

This is the end of the introduction of "how to migrate the docker / var/lib/docker directory". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Directory information transmission work content parameters actual situation file more knowledge space process progress practical great successful learning next company name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei OPPO Reno Shulou Information MySQL Xiaomi