Files
scripts/linux/docker change storage.md
2023-08-16 09:40:44 +00:00

1.7 KiB

Stop the Docker daemon:

sudo systemctl stop docker Copy existing Docker data: If you already have images, containers, and volumes that you want to keep, you'll need to move them to the new location. Replace /new/path with the path to the directory where you want Docker to store its data.

sudo rsync -aP /var/lib/docker/ /mnt/data/docker sudo rsync -aP --info=progress2 /var/lib/docker/ /mnt/data/docker

Edit the Docker configuration file: Open the Docker configuration file with a text editor like nano or vi. The location of this file might vary depending on your Linux distribution, but it's typically found at /etc/docker/daemon.json. If the file doesn't exist, create it.

rm -rf /mnt/data/docker

sudo nano /etc/docker/daemon.json Then add the following content, again replacing /new/path with your desired path:

{ "data-root": "/new/path/docker" } Save and close the file.

Start Docker again:

sudo systemctl start docker Verify the changes: Run a command like docker info | grep "Docker Root Dir" to ensure that Docker is using the new directory.

Optional - Clean up old data: If everything is working fine, and you have made a backup, you may want to remove the old Docker directory to free up space:

sudo rm -rf /var/lib/docker/

rsync -aP /mnt/azure-resource-second-mount/host/mnt/apps/ /mnt/data/apps rsync -aP --info=progress2 /mnt/azure-resource-second-mount/host/mnt/apps/ /mnt/data/apps/ rm -rf /mnt/azure-resource-second-mount/host/mnt/apps/

rsync -aP --info=progress2 /mnt/azure-resource/apps/ /mnt/data/apps/ rm -rf /mnt/azure-resource/apps/

rsync -aP --info=progress2 /mnt/data/apps/ /data/apps rm -rf /mnt/azure-resource/apps/

rsync -aP --info=progress2 /data/apps /mnt/data/apps rm -rf /mnt/azure-resource/apps/