Docker Community Forums

Share and learn in the Docker community.

Docker volume create with local CIFS driver


(Jamiejackson) #1

Hi Folks,

I’m trying to create a volume with CIFS and a local driver.

Direct mounting works:

mount -t cifs -o username=user1,password=user1pass,vers=3.0 \
   //localhost/private /tmp/mediashare

Here’s my attempt with docker volume create:

 docker volume create \
   --driver local \
   --opt type=cifs \
   --opt device=//localhost/private \
   --opt o=username=user1,password=user1pass,sec=ntlm,vers=3.0 \

docker run -it --rm -v mediashare:/tmp/mediashare \
  -d --name samba-client alpine ash

However, here’s the output:

docker: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/mediashare/_data': error while mounting volume with options: type='cifs' device='//localhost/private' o='username=user1,password=user1pass,sec=ntlm,vers=3.0': invalid argument.


This must be old information, since I don’t see a name argument for docker volume create:

I got it working with a plugin (docker-volume-netshare), but I want to try it without.

(Ramizrshaik) #2

I am trying to do the same. How ever i tried something like this.

** type: cifs**
** device: ://windows-share/target-dir**
** o: addr=drive address,rw,username=xxxxxxxxxxx,password=xxxxxxxxxx,uid=zzzzz,gid=zzzzzzz**

but i am getting errors.

if what you said is working “Direct Mounting” is it accessible across all Jenkins slaves?

(Jamiejackson) #3

Mine’s not in the context of Jenkins slaves, FWIW. (The direct mounting option just shows that it’s possible to mount the share with CIFS from the same host, so there’s something wrong with docker volume create or my use of it.)

(Ramizrshaik) #4

Please let me know once you figured it. i am trying to make this work too :slight_smile:

(Jamiejackson) #5

Do you have a forums question open for the Jenkins stuff? If so, please link it, and I’ll post some comments there.

(Ramizrshaik) #6

it is not an issue with jenkins right. this is about creating cifs mount as volume in docker. In my case i am trying to mount this onto jenkins slave as second volume

(Pavel Martynov) #7

I have exactly the same issue. Surpisengly there is no any solution on Google.

(Jamiejackson) #8

I don’t think this thread is going to get any attention. I created a a ticket on GitHub.

(Rlaveycal) #9

I’ve used successfully in the past

(Jamiejackson) #10

Yes, the second reference in my original post details the docker-volume-netshare solution, but I’d like to explore the non-plugin option that supposedly works (but has no documentation).

(Archimedes Trajano) #11

as for me I “partially” got it to work using a compose file

    driver: local
      type: cifs
      o: vers=3.02,mfsymlinks,username=****,password=*****,domain=****
      device: "//noriko/s/wordpress"
#    name: 'noriko/s/wordpress'
#    driver: cifs

The reason I say partially is I only got it to work in docker-compose but not in docker stack deploy

To make this fully work, I need to use the IP address rather than the host name for the device. In addition, if you improperly built this on the swarm you’d have to go to the worker and docker volume rm from there to make sure it gets recreated.

(Crramirez) #12

Probably the problem is missing quotes or extra options like uid:

docker volume create \
   --driver local \
   --opt type=cifs \
   --opt device='//localhost/private' \
   --opt o='username=user1,password=user1pass' \

docker run -it --rm -v mediashare:/tmp/mediashare \
  -d --name samba-client alpine ash

It works for me in this way

(Archimedes Trajano) #13

The way you’re doing it would be on the specific daemon much like docker-compose. I noted that there really isn’t an issue when doing it there, it’s more of a problem when you’re doing a docker stack deploy to a swarm.

(Mark Himsley) #14

This does not work for me. What version of Docker are you using?

$ docker version
 Version:	18.03.0-ce
 API version:	1.37
 Go version:	go1.9.4
 Git commit:	0520e24
 Built:	Wed Mar 21 23:10:09 2018
 OS/Arch:	linux/amd64
 Experimental:	false
 Orchestrator:	swarm

  Version:	18.03.0-ce
  API version:	1.37 (minimum version 1.12)
  Go version:	go1.9.4
  Git commit:	0520e24
  Built:	Wed Mar 21 23:08:36 2018
  OS/Arch:	linux/amd64
  Experimental:	false

$ sudo mount \
>    -t cifs \
>    -o 'guest,vers=1.0' \
>    '//dump/dump' \
>    /mnt

Works just fine, but this doesn’t…

$ docker volume create \
>    --driver local \
>    --opt type=cifs \
>    --opt device='//dump/dump' \
>    --opt o='guest,vers=1.0' \
>    dumpshare

$ docker run -it --rm \
>   -v dumpshare:/mnt \
>   --name test ubuntu:16.04 bash
docker: Error response from daemon: error while mounting volume with options: type='cifs' device='//dump/dump' o='guest,vers=1.0': invalid argument.
See 'docker run --help'.

(Archimedes Trajano) #15

using the sudo approach I take it you can do ls /mnt successfully? Also note the docker mount does not use the mount command by the syscall.Mount for NFS it does not work with host names. However, I did get it working with the host names for my CIFS share at one point. I switched over to a managed plugin now though so it can work in a swarm.

(Mark Himsley) #16

Yes, I can ls /mnt successfully when I use mount from the shell.
I have NFS mounting working perfectly using type=nfs with o=addr=hostname,... I did not need to use an IP address. Getting NFS mounting was so easy - I don’t understand why getting CIFS mounting working is so hard.
Out of interest, which plugin did you successfully use?

(Archimedes Trajano) #17

I used to use ContainX netshare volume plugin but I eventually opted to write my own docker volume plugins because I wanted to have them as managed plugins. That allows me to use CIFS or GlusterFS without having to install the cifs-utils or glusterfs-fuse packages on the host first (everything is self contained in the plugin’s container.

I also have a CentOS Mounted Volume Plugin that would allow you to mount arbitrary file systems assuming the packages are available for CentOS without having to install them directly on the host.

(Martijn Pepping) #18

I was able to make this work by substituting the DNS-name of the CIFS-server with the IP-address of the CIFS-server, in the Compose definition.