> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Change the Docker data-root Directory (Move to Another Disk)

> Change the Docker data-root directory: stop Docker, copy /var/lib/docker to the new disk with rsync, set data-root in daemon.json, and move containerd's storage too.

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`.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Intermediate | 20–60 minutes, depending on data size | Ubuntu, Debian, AlmaLinux, Rocky Linux with Docker Engine | Root or sudo, a mounted disk with enough free space |

## 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](https://help.freakhosting.com/portals/other/how-to-mount-a-new-disk-on-linux.md).
* 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](https://help.freakhosting.com/portals/other/how-to-back-up-docker-volumes.md) or take a server backup first.
* Root users can leave out `sudo`.

## Where does Docker store its data?

```bash theme={null}
docker info -f '{{ .DockerRootDir }}'
docker info -f '{{ .Driver }}'
```

| `Driver` shows | Image store | Where the data is |
| - | - | - |
| `overlayfs` | containerd image store (default on fresh Docker 29 installs) | Images and container layers in `/var/lib/containerd`; volumes and settings in `/var/lib/docker` |
| `overlay2` | Classic storage driver (servers upgraded from older Docker) | Everything in `/var/lib/docker` |

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**

```bash theme={null}
sudo systemctl stop docker.socket docker.service
```

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**

```bash theme={null}
sudo mkdir -p /mnt/data/docker
sudo rsync -aHAX /var/lib/docker/ /mnt/data/docker/
```

`-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.

```json theme={null}
{
  "data-root": "/mnt/data/docker"
}
```

Test it:

```bash theme={null}
sudo dockerd --validate --config-file /etc/docker/daemon.json
```

It prints `configuration OK`.

**4. Keep the old folder aside**

```bash theme={null}
sudo mv /var/lib/docker /var/lib/docker.old
```

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**

```bash theme={null}
sudo systemctl 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**

```bash theme={null}
sudo systemctl stop docker.socket docker.service containerd
```

**2. Copy the data**

```bash theme={null}
sudo mkdir -p /mnt/data/containerd
sudo rsync -aHAX /var/lib/containerd/ /mnt/data/containerd/
```

**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:

```toml theme={null}
root = "/mnt/data/containerd"
```

Leave `disabled_plugins = ["cri"]` and the other lines as they are.

**4. Keep the old folder aside and start both services**

```bash theme={null}
sudo mv /var/lib/containerd /var/lib/containerd.old
sudo systemctl start containerd docker
```

> [!TIP]
>
> 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](https://help.freakhosting.com/portals/other/how-to-use-selinux-on-almalinux-and-rocky.md).

## How to check it worked

```bash theme={null}
docker info -f '{{ .DockerRootDir }}'
docker images
docker volume ls
docker ps -a
```

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:

```bash theme={null}
sudo rm -rf /var/lib/docker.old /var/lib/containerd.old
```

> [!WARNING]
>
> `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

### Can I use a symlink instead of data-root?

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](https://help.freakhosting.com/portals/other/how-to-clean-up-docker-disk-space.md) 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](https://help.freakhosting.com/portals/other/how-to-resize-a-partition-after-a-disk-upgrade.md).

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every guide in this section.

> [card] [Mount a new disk](https://help.freakhosting.com/portals/other/how-to-mount-a-new-disk-on-linux.md)
>
> Format and mount the target disk.

> [card] [Clean up Docker disk space](https://help.freakhosting.com/portals/other/how-to-clean-up-docker-disk-space.md)
>
> Free space before you move anything.

> [card] [Back up Docker volumes](https://help.freakhosting.com/portals/other/how-to-back-up-docker-volumes.md)
>
> A safety copy before the move.

> [card] [Fix No space left on device](https://help.freakhosting.com/portals/other/how-to-fix-no-space-left-on-device.md)
>
> When the disk is already full.

***

> [!NOTE]
>
> **Checked against the official [Docker daemon configuration documentation](https://docs.docker.com/engine/daemon/#daemon-data-directory)** 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.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.