How to Migrate Docker Storage Directory to a Larger Disk on CentOS
This guide explains how to relocate Docker's storage directory to a larger disk on a CentOS system, covering disk addition, partitioning, formatting, mounting, copying data, updating the Docker daemon configuration, and verifying container operation after migration.
Docker stores images and containers under its data directory, which can fill up a small disk and cause failures; migrating the storage directory to a larger disk resolves this.
1. Add a new data disk (e.g., /dev/sdb) to the VM and create a partition using fdisk /dev/sdb, selecting a primary partition, default start sector 2048, end sector 20971519, size 10 GiB, then write the table.
2. Format the new partition with mkfs -t ext4 /dev/sdb1.
3. Mount the new partition to /docker and copy existing Docker data:
mkdir /docker
mount /dev/sdb1 /docker
cp -r /var/lib/docker /docker/4. Update Docker daemon to use the new graph directory by creating /etc/systemd/system/docker.service.d/devicemapper.conf with:
ExecStart=
ExecStart=/usr/bin/dockerd --graph=/docker/dockerReload systemd, restart Docker, and verify with docker info and docker images. After confirming containers run correctly, remove the old /var/lib/docker files and start Docker.
Container operation is restored and data migration is complete.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
