can someone tell me, how and what are the best ways to backup docker containers?
i use proxmox and backing up and rolling the backups are so damn easy for LXC containers, but i have had no easy experience with docker containers.
i was running docker on an debian based LXC before, i thought why not shift to alpine based LXC, but i was facing issues with systemd not being present in alpine. i am thinking of going back to debian based host for docker. but how should i export and import all of my containers and data and everything in a few clicks or commands??
Put them in a Debian VM (from the start) and back that that up?
Migrating docker between hosts is not so simple. I check bash history to save the docker run commands to a text file and then manually backup the directories that are mounted as volumes.
its really irritating to be honest, i am not well versed with these and take help from Gemini, everytime i have had to reinstall os on Pi, same docker doesnt work and this gemini gives different yaml files .. i had to copy the working ones and send to gmail as text
yes backing up the whole lxc or the whole host is way overkill, i dont have too many containers, i kinda prefer lxc just because its easy to maintain, watch and backup.
i use docker compose, @rsaeon docker run is messy, compose creates stack, easier to maintain if alot of containers and similar kind, also easier to change things, for eg, in case you wanna change internal ports of a container you could just change the port from the yaml config and just “docker compose up -d”
i kinda go a step further, i expose the docker sock via tcp and have a vscode server hosted. i expose that sock to that code server and manage my docker compose aswell as my containers directly from it.
the problem comes if i decide to change hosts or if i wanna backup individual containers? at one point i was thinking to go debian or ubuntu way and just running docker for every app, but i couldn’t imagine manually backing up a plex volume just so i could retain the setup and progress of things. it’s just stupid. so i stayed with pve
i am gonna change servers now, so i decided it’s time to change my docker host lol. it’s gonna be a small pain but i guess ill be okay with one time rsync thing. apart from that my docker containers are really barebones, no backup whatsoever, will have to go through setting up things again if i lose them.
some irony, i kinda went straight to some complex docker things like exposing docker sock and shit but never looked at what portainer provides lol, all i use my portainer is for checking my containers and restarting them. apart from that it always looks intimidating to me.
It looks like I’ll need to sit and down and learn docker compose for my homelab, at least. I use docker networking with macvlan to give each container a unique IP so I can stick to using default ports, I’m hoping that’ll translate over as well.
Backing up an entire VM isn’t so bad with snapshots.
My webscrapers used to depend heavily on spinning up thousands of containers across multiple hosts with docker run programmatically and I had just copied that behaviour for the homelab.
say i have plex installed as a docker container and i have other containers too which are big in size but not significantly as important as plex. and if i wanna have multiple timed backups ill have to backup the whole system, and in each backup it will include the other containers too. and then if i wanna revert to certain backup of plex, the changes made to other containers will also get reverted.
it can be done if all you wanna do is just one incremental backup. but the argument here is just that it’s not ideal
also did you know that you can configure ports such that the internal stays as is only it appears something else in the host machine. say i have dns hosted on docker at port 53, i can change the ports like 53:6969 so it will use host:6969 but will stay as port 53 inside the docker container.
But for your use case I guess you could commit the the compose, env and data directories to version control? Then you can just recreate the relevant container from previous config files.
Another solution I can think of is using rysnc or syncthing.