Skip to main content
To change the Docker data-root directory, stop Docker, copy /var/lib/docker to the new disk with sudo rsync -aHAX /var/lib/docker/ /mnt/data/docker/, add "data-root": "/mnt/data/docker" to /etc/docker/daemon.json and start Docker again. On new Docker 29 installs, images are stored by containerd in /var/lib/containerd, so move that folder too by setting root in /etc/containerd/config.toml.

Before you start

  • Mount the new disk first, with an /etc/fstab entry so it mounts at boot. This guide uses /mnt/data. See mount a new disk on Linux.
  • Use a local Linux filesystem such as ext4 or XFS. Docker’s docs warn against sharing one data directory between two daemons, for example over NFS.
  • All containers stop while you move the data. Plan a short maintenance window.
  • Back up your volumes or take a server backup first.
  • Root users can leave out sudo.

Where does Docker store its data?

Check which folder is large with sudo du -sh /var/lib/docker /var/lib/containerd.

How to move the Docker data directory

1

Stop Docker

Stopping docker.socket as well stops it from starting Docker again on the next docker command. Wait until systemctl is-active docker prints inactive.
2

Copy the data

-aHAX keeps permissions, owners, hard links, ACLs and extended attributes. The trailing slashes copy the folder’s contents.
3

Set data-root

Create or edit /etc/docker/daemon.json. If the file already has settings, add the line inside the existing braces.
Test it:
It prints configuration OK.
4

Keep the old folder aside

If Docker were still reading the old path by mistake, it would now start empty instead of silently using the old data.
5

Start Docker

How to move containerd’s image storage

Do this as well if docker info showed overlayfs, because your images are in /var/lib/containerd, which data-root doesn’t change.
1

Stop Docker and containerd

2

Copy the data

3

Set the new root

Open /etc/containerd/config.toml. The file installed with Docker has the line #root = "/var/lib/containerd". Remove the # and change the path:
Leave disabled_plugins = ["cri"] and the other lines as they are.
4

Keep the old folder aside and start both services

On AlmaLinux or Rocky Linux with SELinux enforcing, give the new folders the same SELinux labels as the old ones before you start Docker: sudo semanage fcontext -a -e /var/lib/docker /mnt/data/docker, sudo semanage fcontext -a -e /var/lib/containerd /mnt/data/containerd, then sudo restorecon -R /mnt/data/docker /mnt/data/containerd. See use SELinux on AlmaLinux and Rocky.

How to check it worked

The first line prints /mnt/data/docker. Your images, volumes and containers are all listed. Start your apps (docker compose up -d in each project folder) and check that their data is there. Containers with a restart policy start on their own. When everything has worked for a few days, delete the old copies to free the space:
rm -rf can’t be undone. Check the path twice and only run it after you have confirmed the apps and their data work from the new disk.

How to roll back

Stop Docker (and containerd), move the .old folders back to their original names, remove the data-root line (and set root back to /var/lib/containerd), then start the services again.

Frequently asked questions

Docker documents the data-root setting for this, so use it. A symlink or bind mount of /var/lib/docker can work, but some tools resolve paths differently and it is harder to see later what you changed.

Can I move only the volumes?

Not with a Docker setting: volumes always live under data-root. To keep a single app’s data elsewhere, use a bind mount in its compose.yaml, such as /mnt/data/nextcloud:/var/www/html.

Why is the disk still full after moving?

The old copy is still there until you delete the .old folders. Also check for large container logs, which log rotation limits.

My VPS got a bigger disk. Do I need to move Docker?

No. Grow the existing partition instead; see resize a partition after a disk upgrade.

VPS and dedicated server guides

Every guide in this section.

Mount a new disk

Format and mount the target disk.

Clean up Docker disk space

Free space before you move anything.

Back up Docker volumes

A safety copy before the move.

Fix No space left on device

When the disk is already full.

Checked against the official Docker daemon configuration documentation on 4 November 2026; the stop, rsync, data-root and start steps tested on Ubuntu 24.04 LTS with Docker Engine 29.9.2 (images, volumes and containers all present afterwards), daemon.json validated with dockerd --validate, and the config.toml change checked with containerd config dump (containerd 2.4.2). Commands can differ on other distributions or releases.

Need Extra Help?

If you encounter any issues, our support team is ready to assist:

Save on Your Hosting

Ready to upgrade your hosting? Use code KB20 at checkout for 20% off your first order!

Last Updated: November 2026