An interactive helper for moving Docker's data-root to a larger disk safely.
It builds on the original docker-data-move.sh idea, but adds:
- automatic detection of the current Docker data directory
- automatic disk scanning and free-space comparison
- recommended target paths sorted by available space
- interactive selection or
--automode - safer pre-checks for free space, path nesting, and
daemon.json - backup of the old Docker data directory and Docker config
A common production problem looks like this:
/homeor/varis full- Docker overlay layers live under the full filesystem
- another mount such as
/datastill has hundreds of GB free
This script helps you move Docker data to the larger mount with less manual work.
- Detects Docker's current
data-root - Calculates how much free space the migration target should have
- Scans local filesystems and suggests the best candidate paths
- Lets you choose a suggested path or enter a custom path
- Stops Docker and
containerd - Copies Docker data with
rsync - Updates
/etc/docker/daemon.json - Restarts Docker
- Verifies the new
Docker Root Dir
Interactive mode:
sudo ./docker-data-move.shSpecify a target path directly:
sudo ./docker-data-move.sh --path /data/docker-dataAuto-pick the best detected path:
sudo ./docker-data-move.sh --autoSkip confirmation prompts:
sudo ./docker-data-move.sh --auto --yesAllow using a non-empty target directory:
sudo ALLOW_NONEMPTY=1 ./docker-data-move.sh --path /data/docker-dataIf your machine looks like:
/home 100% used
/data plenty of free space
the script will typically recommend a target like:
/data/docker-data
- Linux
- Docker installed
rsyncavailable- root privileges
Optional:
jqfor safer JSON updates to/etc/docker/daemon.json
- The script avoids recommending the same filesystem that currently stores Docker data.
- It keeps a backup of the old Docker data directory as
...bak.TIMESTAMP. - If
daemon.jsonalready exists, it is backed up before modification.
docker info | grep "Docker Root Dir"
docker ps
df -h- GitHub: tool-tl/docker-data-move.sh