TIL: save the state of a Docker container with docker export
2021-01-01 00:00:00 +0000 UTCThe recommended way to back up a running container is to run docker export. This command produces a tarball that can later be consumed by docker import to bring up a new container in the same state as the moment it was exported.
For my homelab and software projects, I currently use an instance of DokuWiki to keep notes about progress, learnings, and future ideas someplace other than in my head. DokuWiki is open-source wiki software that runs without a database. I primarily chose it for that feature – it means it’s very easy to set up in a Docker container and has low technical overhead. Less can go wrong when you’re just writing and reading files.
On the other hand, because I’m running my DokuWiki instance in a Docker container, the DokuWiki backup process – just copy all of the files – is less accessible. You can find standard Docker volumes on the filesystem, but tinkering there is discouraged.
I’m not fully satisfied because the archive has the bloat of the full container state. I’d prefer just to back up the text of the wiki. I won’t use this solution for backups forever. But it was a quick and easy way to make sure I didn’t lose my notes when I needed to power down the host running my wiki. But for now throwing a .tar.gz into an s3 bucket is good enough.