Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report