Operations 5 min read

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.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
How to Migrate Docker Storage Directory to a Larger Disk on CentOS

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/docker

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

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

linuxSystem AdministrationCentOSStorage Migration
Practical DevOps Architecture
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.