Migration of Docker root directory #2527
|
What is the proper procedure for migrating the Docker root directory to external storage without breaking CasaOS App Management? By default, CasaOS installs all Docker containers, images, and volumes to the host's primary root drive (typically /var/lib/docker). For users running CasaOS on single-board computers (like a Raspberry Pi) or small boot SSDs, this partition quickly runs out of space. If we want to change the global Docker root directory (data-root) to a mounted external storage drive (e.g., /media/devmon/HDD1), what is the safest and most compliant procedure to ensure that casaos-app-management completely recognizes the transition and successfully tracks existing/new containers? |
Replies: 1 comment
Migrating the Docker daemon's storage root requires stopping the Docker and CasaOS engine components, moving the existing assets safely, and updating the Docker daemon schema.Follow this step-by-step procedure via CLI: 1. Stop CasaOS and Docker ServicesBefore moving any data, you must halt all write operations by stopping both CasaOS services and the underlying Docker engine: sudo systemctl stop casaos-app-management.service
sudo systemctl stop casaos.service
sudo systemctl stop docker.service
sudo systemctl stop docker.socket2. Configure Docker to use the New PathCreate or modify the Docker daemon configuration file located at {
"data-root": "/media/devmon/HDD1/docker-root"
}3. Migrate Existing Docker DataSync your existing data, containers, layers, and volumes over to the new directory while preserving all original file permissions and timestamps: # Ensure the target directory exists
sudo mkdir -p /media/devmon/HDD1/docker-root
# Sync the data safely
sudo rsync -aP /var/lib/docker/ /media/devmon/HDD1/docker-root/4. Start the Engines and VerifyReload the system configurations and start the services back up: sudo systemctl daemon-reload
sudo systemctl start docker.service
sudo systemctl start casaos.service
sudo systemctl start casaos-app-management.serviceVerify that Docker is successfully operating out of the new directory by checking the execution layout: docker info | grep "Docker Root Dir"(It should accurately print: 5. Clean Up Old AssetsOnce you have verified that your Web UI is active and all of your CasaOS apps spin up properly with their data intact, you can safely remove the legacy storage directory to reclaim space on your primary drive: sudo rm -rf /var/lib/docker |
Migrating the Docker daemon's storage root requires stopping the Docker and CasaOS engine components, moving the existing assets safely, and updating the Docker daemon schema.
Follow this step-by-step procedure via CLI:
1. Stop CasaOS and Docker Services
Before moving any data, you must halt all write operations by stopping both CasaOS services and the underlying Docker engine:
2. Configure Docker to use the New Path
Create or modify the Docker daemon configuration file located at
/etc/docker/daemon.json. Add or update the"data-root"ke…