Home > Operation and Maintenance > Docker > How to change the docker storage directory

How to change the docker storage directory

王林
Release: 2020-12-23 09:51:11
forward
4419 people have browsed it

How to change the docker storage directory

Background of the article:

In the development environment, because the docker test server runs too many containers and images, the disk space is often filled up. So now I decided to change the docker storage directory to the new mount point.

(Learning video sharing: Programming video)

1. Check Docker disk usage

docker system df
Copy after login

2. Clean the disk

docke system prune
Copy after login

Delete useless data volumes of closed containers and network untagged images -a parameter Useless images will also be deleted (use with caution)

3. Stop the Docker service

systemctl stop docker
Copy after login

4 , Migrate data directory

rsync -avz /var/lib/docker /data/docker/lib/
Copy after login

/var/lib/docker: docker default data directory/var/lib/docker: target directory, you need to create it before execution

5. Configure mapper File

Modify according to the installation configuration file of the docker service

vi /usr/lib/systemd/system/dokcer.service
Copy after login

Add attributes in ExectStart=xxx

ExectStart=xxx --graph /data/docker/lib/docker
Copy after login

Re-update the docker service

systemctl disable docker
systemctl enable docker
systemctl daemon-reload
systemctl start docker
Copy after login

6 . Check

docker info
Copy after login

and you will see the following information indicating success.

Docker Root Dir: /data/docker/lib/docker
Copy after login

Execute docker images and you will see that all previous images have been synchronized.

Related recommendations: docker tutorial

The above is the detailed content of How to change the docker storage directory. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template