Quick answer

What this guide helps you do

Move Docker's data root to another mounted drive with identity checks, a complete stop, a reversible copy, daemon configuration and reboot verification.

Understand the scope

Docker’s data root contains images, writable layers, metadata and usually local volumes. Moving it requires downtime. It does not move bind-mounted application directories. Keep the original data until the new location survives reboot and application checks.

Inventory and back up

sudo docker info --format '{{.DockerRootDir}}'
sudo docker system df -v
sudo docker ps -a
sudo docker volume ls
df -hT
lsblk -o NAME,SIZE,FSTYPE,UUID,MOUNTPOINTS,MODEL

Back up Compose files, secrets and persistent state. Create application-consistent database exports.

Verify the destination

This example uses /srv/docker-data. Prove /srv is the intended filesystem and has enough space:

findmnt /srv
df -hT /srv
sudo mkdir -p /srv/docker-data

Configure the drive by UUID and test it separately before continuing.

Stop and copy

Stop every Compose project, then Docker:

sudo systemctl stop docker docker.socket containerd
sudo systemctl is-active docker

Copy without deleting the source:

sudo rsync -aHAXx --numeric-ids --info=progress2 /var/lib/docker/ /srv/docker-data/
sudo rsync -aHAXx --numeric-ids --delete --dry-run /var/lib/docker/ /srv/docker-data/

Review the dry-run. Never point a real delete operation at an unverified target.

Set the data root

Merge this key into valid /etc/docker/daemon.json rather than overwriting other settings:

{
  "data-root": "/srv/docker-data"
}

Validate:

python3 -m json.tool /etc/docker/daemon.json

Start, reboot and roll back

sudo systemctl start containerd docker
sudo docker info --format '{{.DockerRootDir}}'
sudo docker ps -a

Start projects and check real data, then reboot. After reconnecting, verify /srv mounts before Docker and the root path remains correct.

If Docker fails, stop it, restore the previous daemon configuration and start it against the untouched original data. Read journalctl -u docker -b for the first failure.

Verification checklist

  • Current root and size were recorded.
  • Consistent application backups exist.
  • Destination identity and space were verified.
  • Docker was stopped for the copy.
  • Numeric ownership and metadata were preserved.
  • Original data remains for rollback.
  • Applications contain expected data.
  • Reboot ordering is correct.

These safeguards are not evidence that every filesystem combination has been tested by SmallGrid.

Next: Back Up and Restore Docker Compose Services. Start with How to Install Docker on Ubuntu Server.

Official reference: Docker daemon configuration.