Changing the Docker Engine data directory moves the daemon's persistent state off the default system disk and onto a filesystem with more space or better performance. This is the usual fix when /var/lib/docker grows faster than the root volume can safely handle.
On current Linux hosts, the daemon reads its main storage path from /etc/docker/daemon.json and reports the active root through docker info. Upgraded hosts that still use classic storage drivers keep Docker data under /var/lib/docker, while fresh Docker Engine 29 installs that use the containerd image store keep image contents and container snapshots under /var/lib/containerd instead.
These steps assume a rootful Docker Engine installation managed by systemd. Stop the daemon before copying data, keep the original directories in place until the restart succeeds, and remember that rootless Docker uses different config and service paths.
$ docker info --format '{{.DockerRootDir}}'
/var/lib/docker
$ docker info --format '{{json .DriverStatus}}'
[["Backing Filesystem","extfs"],["Supports d_type","true"],["Using metacopy","false"],["Native Overlay Diff","true"],["userxattr","false"]]
If the output looks like the example, the host is using classic storage drivers and changing data-root covers the whole Docker root. If the output is
[["driver-type","io.containerd.snapshotter.v1"]]
, image contents and container snapshots remain under /var/lib/containerd until containerd is moved separately.
$ sudo mkdir -p /mnt/docker-data
Replace /mnt/docker-data with the final mount point chosen for Docker storage. The destination should already exist on the disk or partition that will hold the data.
$ sudo systemctl stop docker
Stopping Docker stops running containers on the host and can interrupt workloads until the daemon starts again.
$ sudo systemctl stop containerd
Hosts that still use classic storage drivers can leave containerd alone because their Docker data remains under /var/lib/docker.
$ sudo cp -a /var/lib/docker/. /mnt/docker-data/
Keep /var/lib/docker in place until the daemon starts cleanly from the new path and the expected images, containers, and volumes are visible after the restart.
$ sudo mkdir -p /mnt/containerd-data
$ sudo cp -a /var/lib/containerd/. /mnt/containerd-data/
Do not point containerd at the same directory used for Docker's data-root. The two daemons need separate storage roots.
{
"data-root": "/mnt/docker-data"
}
If /etc/docker/daemon.json already contains other keys, add or update only the data-root line inside the existing JSON object. If dockerd already gets --data-root from a systemd unit override, remove or update that override before restarting.
version = 2 root = "/mnt/containerd-data"
This file is needed only for hosts using the containerd image store. Classic storage-driver hosts can skip this step.
$ sudo systemctl start containerd
$ sudo systemctl start docker
$ docker info --format '{{.DockerRootDir}}'
/mnt/docker-data
$ docker image ls WARNING: This output is designed for human readability. For machine-readable output, please use --format. IMAGE ID DISK USAGE CONTENT SIZE EXTRA alpine:3.22 55ae5d250cae 13.5MB 4.23MB
Remove or archive the old /var/lib/docker and /var/lib/containerd trees only after this check and the expected workload startup succeeds.