Running out of disk space with Docker

I’m running a small cloud based server as a redundency server for The Graph indexing.

When setting it up I initially under estimated the amount of diskspace that would be required to maintain an index of four different subgraphs, and ended up running out of room.

To fix the issue, I purchased another volume for the server with 1TB of space and mounted it to mnt/docker-backup.

From there I use the rsync command to copy all of the docker files across to the new larger storage space.

## bring down the docker instances ready to copy
docker-compose down  

## copy all the files/folders/permissions/ownerships across
rsync -avz /var/lib/docker/ /mnt/docker-backup/

Using rsync takes a while.

Once it was copied across I ran the rsync command one more time to ensure no files had updated (they hadn’t).

Next step is to remove the old docker folders

rm -rf /var/lib/docker/

This actually removed the docker folder itself, so I then needed to recreate it to remount the volume there.

mkdir /var/lib/docker

With the folder back and empty (to free up the diskspace that had all been used up) we can not unmout the drive from its current location and remount it to the docker folder.

umount /mnt/docker-backup
mount -o discard,defaults /dev/disk/by-id/scsi-0HC_Volume_14475251 /var/lib/docker/

You should now find the the docker folder with all the files as needed.

Lastly, you need to update the /etc/fstab so that the drive remounts when the server reboots.

Edit the location of the mount by doing nano /etc/fstab and updating a line similar to below

#It was this 
/dev/disk/by-id/scsi-0HC_Volume_14475251 /mnt/docker-backup ext4 discard,nofail,defaults 0 0

#updated it to this
/dev/disk/by-id/scsi-0HC_Volume_14475251 /var/lib/docker ext4 discard,nofail,defaults 0 0

Leave a comment

Your email address will not be published.