Creating Container Using Mounted Share as Volume

Hey Guys -

I currently have a dedicated Docker host (Atomic Fedora 29) set up at home which I use about 15 containers in for development. I love it! When adding a new container today, I ran into an issue so wanted to post before I messed something up.

The Issue

When creating most containers I currently use, I create at least one volume for them to write data to or whatever. The container I am trying to add requires reading data which I have available on my Windows system.

I mounted the Windows share on the host (Atomic Fedora 29) to “/var/roothome/shares/data”, set permissions to 0777, and was able to successfully browse the files afterwards. When trying to start my new container for which I created by adding the above path as a volume, I get an error. Below is the error followed by the string I used to create the container - which is the same format of string I’ve used to create all the ones i currently use:

The Error

Failure: error setting label on mount source ‘/var/roothome/shares/data’: SELinux relabeling of /var/roothome/shares/data is not allowed: “operation not supported”

String Used to Create Container

docker create \
--name="container1" \
-v /var/roothome/container1/data:/config:z \
-v /var/roothome/container1/downloads:/downloads:z \
-v /var/roothome/shares/data:/data:z \
-e PGID=0 -e PUID=0 \
-e TZ=America/Chicago \
-p 1185:1185 \
linuxserver/container1

What I’ve Tried

I found a few pages where it seems I should try to use “–mount” instead of “-v” to attach the mounted share to the container. The thing is, I see plenty of options and the last thing I want to do is jeopardize my shared data.

Based on this, it seems I should be able to swap out the line

-v /var/roothome/shares/data:/data:z \

with something like

--mount type=bind,source=/var/roothome/shares/data,target=/data \

but when I try to do so I’m told that “–mount” isn’t a valid option. Overall, what would be the best way to accomplish what I’m trying to achieve?

Any suggestions? Thanks!

Update

I just tried creating the container using the same string above, but removing “:z” from the end of it. I successfully started after creating it that way, but I got Permission Denied when CDing to the path in the container and attempting an “ls”. Still looking for solution… Thanks

Update #2
I decided to try a different course of action so created the container without the line that attaches a volume to /data. Once I started it, I connected to a console, edited /etc/fstab, pasted in my string used on the host to map / mount the share, saved, then exited. I executed “mount -a” which ran without errors, but when I browsed to /data on the container and executed “ls”, it was empty. Argh! Quest continues… Thanks

Bump :slight_smile: - any suggestions, guys? Thanks!