docker's / var / lib / docker Directory Migration

1 Stop docker Service

systemctl stop docker

2 Create a new directory docker

mkdir -p /data/docker/lib

3 Migration / var / lib / docker

rsync -avz /var/lib/docker /data/docker/lib/

4 modified configuration path

Method 1: by establishing a flexible connection, the / var / lib / docker move to other places, where establishing a soft connection

ln  -s /data/docker/lib /var/lib/docker

Method 2: Modify the default configuration file /etc/docker/daemon.json

{
  "registry-mirrors": ["http://hub-mirror.c.163.com"],
  "graph":"/data/docker/lib"
}

 Method 3: Modify systemd docker's docker.service profile

Profiles do not know where to use systemd command to display it.

systemctl disable docker
systemctl enable docker

#Show results

Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

Open docker.service file.

vim /usr/lib/systemd/system/docker.service

After the increase of the inside rear EXECStart follows

ExecStart=/usr/bin/dockerd --graph /data/docker/lib

Methods: 4: fstab to mount

Vim / etc / fstab
 # Add the last line
 / Data / Docker / lib / var / lib / Docker the bind none             0  0

 5 reload docker

systemctl daemon-reload
systemctl restart docker
systemctl enable docker

6 Delete / var / lib / docker

rm -rf /var/lib/docker

 

Guess you like

Origin www.cnblogs.com/ejiyuan/p/12241998.html