Reputation: 6030
Is there a way to access the hosts zfs snapshots from within the docker?
I'm trying to get some custom backup, using zfs snapshots with send/receive, running on a cluster of docker based servers. To stick to the current setup, I'd like the backup service to run in a docker container as well. I'm having a hard time figuring out if there's any way to access the hosts file system, on an administrative level, from within a docker container.
I basically need a way to run zfs list
, zfs snap
and zfs send
from within the container. My gut tells me "no", but maybe there's a clever way by some mount options and privilege wizardry
Upvotes: 3
Views: 2324
Reputation: 996
Znapzend (a backup utility using ZFS snapshots) covers this in their github page: https://github.com/oetiker/znapzend#running-in-container. I'm using this to automate backups on my NAS to a separate offsite backup NAS.
Here's the relevant info from the link:
---SNIP---
znapzend is also available as docker container image. It needs to be a privileged container depending on permissions.
docker run -d --name znapzend --device /dev/zfs --privileged \
oetiker/znapzend:master
To configure znapzend, run in interactive mode:
docker exec -it znapzend /bin/sh
$ znapzendzetup create ...
# After exiting, restart znapzend container or send the HUP signal to
# reload config
By default, znapzend in container runs with --logto /dev/stdout. If you wish to add different arguments, overwrite them at the end of the command:
docker run --name znapzend --device /dev/zfs --privileged \
oetiker/znapzend:master znapzend --logto /dev/stdout --runonce --debug
Be sure not to daemonize znapzend in the container, as that exits the container immediately.
---SNIP---
Upvotes: 1
Reputation: 11
for me it worked with:
Upvotes: 1
Reputation: 156
I use rancherOS 1.3.0 with zfs on /mnt i start container with:
privileged: true
pid: host
volumes:
- /mnt:/mnt:shared
with this confis i can clone snaphots
Upvotes: 1
Reputation: 7737
Unfortunately, there is no way to do that. We've had the same problem ourselves, and the way we worked around it was by creating a container-less service which the containers can issue commands to, and the container-less service could then issue ZFS commands on their behalf and return the results. It's not a perfect solution, but (at least for us) it was better than nothing.
Upvotes: 0