I've set up Docker on an Ubuntu server VM running on Proxmox, but I'm quickly running into space issues after creating a few stacks. I've learned that to prevent this, I should create a new disk for the Docker data directory. I've already added a 100 GB disk to the VM since there's plenty of space available. Now, I'm unsure of the next steps. How do I move the /var/lib/docker directory to this new disk? Should I do it while setting up Docker, or is it better to do it afterward? Any guidance would be appreciated!
5 Answers
You can just stop Docker, then move all the files from the old directory to your new disk. It’s pretty straightforward. Just remember to stop the service first, so there are no issues with anything that's currently running.
It’s often cleaner to mount a different disk directly at the default path for Docker. So you could do that instead of moving files manually, and it keeps things organized.
Consider changing the Docker data root directory instead. You can do this by editing the /etc/docker/daemon.json file to point to your new disk. Just make sure to stop the Docker service before you make any changes to avoid a mess!
If you want to get around size issues altogether, I usually just resize the filesystem rather than setting up separate disks for /var/lib/docker, but if you prefer going the dedicated disk route, then make sure it’s mounted on that path cleanly.
I had the same space problems in the past! Just be careful during the transition. After stopping Docker, ensure everything is backed up before moving files.

Related Questions
How To Get Your Domain Unblocked From Facebook
How To Find A String In a Directory of Files Using Linux