1

I have Docker 18.06.1-ce running on Ubuntu 18.04. Docker is running on a ext4 file system.

I have a raid array for big storage running ZFS. I would like to mount a directory from the ZFS array into a container. However, when attempting this, I get the following error:

docker run -it -v /mainpool/test:/mnt/mainpool busybox
docker: Error response from daemon: error while creating mount source path '/mainpool/test': mkdir /mainpool: read-only file system.

With some searching, I have seen some others have had the same issue. Like: https://www.reddit.com/r/docker/comments/93u3hf/unable_to_mount_zfs_host_directory_in_container

I do not want to move Docker to the ZFS file system for performance reasons. And it sounds like /var/lib/docker is a required to be in ZFS to use the ZFS storage driver.

Anyone have any thoughts on how to get around this?

EDIT: adding more info.

I am running Docker 18.06.1-ce in a snap. I am using the default daemon.json provided with the snap:

    "log-level":        "error",
    "storage-driver":   "aufs"

Some possible useful info from Docker:

Storage Driver: aufs
 Root Dir: /var/snap/docker/common/var-lib-docker/aufs
 Backing Filesystem: extfs
 Dirs: 192
 Dirperm1 Supported: true
Security Options:
 apparmor
 seccomp
  Profile: default
Docker Root Dir: /var/snap/docker/common/var-lib-docker

Possible relevant info from /proc/mounts:

/dev/nvme0n1p2 / ext4 rw,relatime,data=ordered 0 0
/dev/loop8 /snap/docker/321 squashfs ro,nodev,relatime 0 0
nsfs /run/snapd/ns/docker.mnt nsfs rw 0 0
mainpool /mainpool zfs rw,xattr,noacl 0 0 
Will K
  • 21
  • 4
  • That bind mount should really just work. Don't get distracted by Docker-ZFS support, which is a totally different feature, because I suspect that all you want is mounting a directory as a volume in your container. it's probably something really simple we're not seeing here. Could you post the output of `cat /proc/mounts` and the configuration for your docker daemon where it holds the '/var/lib/docker` data? My guess is that your Docker data folder is read only mounted or something. – gertvdijk Feb 17 '19 at 22:23
  • @gertvdijk, sorry for the late response and thanks for responding! I was thinking something along the same lines. I have edited my post with hopefully the info you are looking for. – Will K Feb 20 '19 at 04:10
  • 1
    You're running Docker inside another container engine (snap)? And then also, why `aufs`? Is your kernel heavily out of date not providing `overlayfs`? I think you have more issues than just a failing bind mount here. I think this Q&A site is not suitable for a broader discussion, really. Perhaps just start off by running Docker the regular way... – gertvdijk Feb 21 '19 at 09:33
  • I am a little new to snap. During the install of Ubuntu 18.04 server, it asked if I wanted to install any apps from a list. Docker was one of them. It installed it with snap (I assumed it would have just been from apt). This is a fresh install of Ubuntu 18.04 with latest Docker via snap with default configuration. So, I don't think running docker via the snap package is inherently wrong. Though, maybe there is an issue with it's configuration or "containerization" through snap with what I am trying to do. – Will K Feb 21 '19 at 16:42
  • Do you believe it's more likely that I'm running docker from snap or that the storage driver is aufs instead of overlayfs? I suppose that either of those answers means I should reinstall docker from apt and configure it with overlayfs. – Will K Feb 21 '19 at 16:43

2 Answers2

1

@gertvdijk was correct.

After reinstalling docker from apt (outside snap) and making sure it was configured to use the overlay2 storage driver, I am able to bind mount directories on my zfs pool.

So, either running docker in a snap or using the aufs storage driver (instead of overlay2) was causing the issue with trying to mount directories from a zfs pool.

Will K
  • 21
  • 4
0

I encountered the same error. I could not mount a directory from a ZFS dataset. Docker was installed as a snap, although it was using the overlay2 storage driver. I as well have remove docker (as a snap), installed it with apt and set the storage driver to overlay2. Now it works like a charm.