1. Scenario description
1. The disk space of the physical machine is not enough.
2. The default path of docker images, containers, volumes and other data is: /var/lib/docker
3. The data disk is added, and all docker data needs to be replaced with a directory
2. Operation
Confirm whether the switching conditions are met
1) Whether the service can be suspended, if so, OK
2) The core data conditions can be backed up, the service can be suspended, and the data cannot be lost
Confirm docker status
systemctl status docker
stop docker
systemctl stop docker
docker migration
rsync -r -avz /var/lib/docker /mnt/data/data131/docker
1) Data disk mapping relationship:
nas disk: {nas.ip}:/mnt/data/data131/docker
physical machine: /mnt/data/data131/docker
2) Time-consuming, too much data in images, containers, and volumes
Backup docker original soft route
mv /var/lib/docker /var/lib/docker-old
Create a new soft route
ln -s /mnt/data/data131/docker /var/lib/docker
start docker
systemctl start docker
View docker status
systemctl status docker
1) If it is normal, it is OK
View docker disk usage
docker system df
1) At this point, ok
2) After 10, it is the verification process
create volume
docker volume create uptime-kuma
View volume location
cd /mnt/data/data131/docker/volumns
ll
1) The volume creation is ok, and the location is correct
2) The operation is very smooth, and I wish the same
3) I found that during the migration process, there is no need to stop the container; and docker ps found that it still runs again; it is almost 6