I'm diving into Docker as I build out my homelab with containers, but before I rely on them for anything important, I want to ensure my setup has solid foundations. I've set up about 10 containers across two minimized Ubuntu Server hosts, creating individual directories for each container in /opt/docker/. I also bind-mount any required volumes to subdirectories within that path. For instance, /opt/docker/nginx-proxy-manager/ has a docker-compose.yaml file along with data/ and letsencrypt/ folders. My goal is to backup the entire /opt/docker/ directory periodically to simplify restoration on a new machine if needed. Am I doing this right, or is there a better approach? I should note that some data is on a network share mounted under /mnt, with cases like Immich where the database and media are separated. Any advice?
2 Answers
This approach is totally valid for data retention! I might suggest considering a subdirectory in /var or perhaps a different mount point just based on personal preference, but /opt works too if that’s what feels right for you!
Sounds like you’re on the right track! I’ve done something similar and it worked flawlessly when I had to migrate hosts a couple of times. Keeping everything organized like that makes backups a breeze!

What’s the reasoning for choosing /var over /opt? I’ve seen both recommended, but opted for /opt since it seemed more POSIX compliant!