I recently set up Docker on a Proxmox Ubuntu server VM and quickly ran into issues with running out of space after creating a few stacks. To tackle this, I added a new disk to my Ubuntu server VM with 100 GB of space, given that it's on a NAS. Now, I'm trying to figure out the best way to move the var/lib/docker directory to this new disk. Should I do this during the Docker setup or after it's already running? What steps should I follow to do this properly? Thanks!
3 Answers
You can easily stop Docker, then move all the files from the current location to the new disk. After that, just mount it to the var/lib/docker directory. It’s pretty straightforward!
Instead of creating a separate var/lib/docker, consider resizing the filesystem. I usually avoid multiple virtual disks in VMs and use LVM for better management of filesystems.
A clean way to handle this is to edit the /etc/docker/daemon.json file. Set the 'data-root' to your new disk location. Just remember to stop the Docker service before moving the files; otherwise, you'll run into issues.

Thanks for the tips! I'll definitely follow that approach.