Migrate Docker Data Directory on CentOS 7
·1 min read·BIGWONG Studio
Docker
When disk space is low, move Docker's data directory from /var/lib/docker to another location.
- Back up
/var/lib/docker
mv /var/lib/docker /var/lib/dockerbak
- Copy data to the new location
cp -rp /var/lib/docker /some-new-dir
- Symlink the new directory back
ln -s /some-new-dir/docker /var/lib/docker
Note: After this step, the original directory path becomes the symlink. If you need the original folder again, remove the symlink.
- Restart Docker twice (this is how I did it; I no longer remember why)
systemctl restart docker
systemctl restart docker
- Verify disk usage
docker ps -s
If everything is fine, you can delete the old backup to save space.