Relocate Docker's Data Files¶
old_path=/var/lib/docker
new_path=/home/docker
systemctl stop docker
rsync -avPAX "${old_path}"/ "${new_path}"/
mv "${old_path}" "${old_path%%/}_OLD"
( cat /etc/docker/daemon.json 2>/dev/null || echo '{}' ) \
| jq --arg new_path "${new_path}" '.["data-root"] = $new_path' \
| sponge /etc/docker/daemon.json
systemctl start docker
When you are 100% sure that everything is fine:
rm -rf "${old_path%%/}_OLD"