Change Docker’s Data Storage Location on Linux
📘 Overview
By default, Docker stores all its images, containers, and volumes under the directory /var/lib/docker
.
However, you might want to move this directory to another drive or partition — for example:
- Free up space on your system drive
- Use a faster SSD
- Keep Docker data separate from the OS
This guide explains how to safely change Docker’s storage path for native Linux installations (not Docker Desktop).
🧭 Table of Contents
- Stop Docker Service
- Copy Existing Data (Optional)
- Configure Docker Daemon
- Reload and Restart Docker
- Verify the Change
- Important Notes
Stop Docker Service
Before making any changes, stop the Docker daemon to avoid data corruption:
sudo systemctl stop docker
Copy Existing Data (Optional)
If you already have Docker images, containers, or volumes you want to keep, copy them to the new location:
sudo rsync -aP /var/lib/docker/ /path/to/new/docker/root/
🗂️ Replace
/path/to/new/docker/root/
with your desired directory, e.g./mnt/data/docker
.
Configure Docker Daemon
Edit or create the Docker daemon configuration file:
sudo nano /etc/docker/daemon.json
Add or modify the following line:
{
"data-root": "/path/to/new/docker/root"
}
Reload and Restart Docker
Once configured, reload the system daemon and restart Docker:
sudo systemctl daemon-reload
sudo systemctl start docker
Verify the Change
Check that Docker is now using the new directory:
docker info | grep "Docker Root Dir"
You should see the path you configured earlier.
⚠️ Important Notes
🧾 Permissions
Ensure the new directory is owned by root
and has proper permissions:
sudo chown -R root:root /path/to/new/docker/root
💾 Disk Space
Select a disk or partition with enough space for your Docker data.
🧰 Backup
Always back up important Docker data before making major configuration changes.