大网数据广告活动
服务器运维问答

How to create CIFS docker volume with username, password, uid, and gid

· 52CE 我爱测

I am trying to create docker volumes using the docker-volume-netshare driver from here: https://github.com/ContainX/docker-volume-netshare The sequence should be like this: docker volume create -d cifs <some_options> docker run -…

问题原文

原帖链接 · Mikkel · CC BY-SA 3.0

I am trying to create docker volumes using the docker-volume-netshare driver from here: https://github.com/ContainX/docker-volume-netshare

The sequence should be like this:

docker volume create -d cifs <some_options>
docker run -v <the_volume> <other_docker_options>

and I can get it to work part of the way but for the life of me I can't get it to pass all the options I need.

Instead of trying to recount my countless different failure modes, I would prefer to state my goal. Underneath, docker-volume-netshare will execute a mount -t cifs ... command. This can be seen in the log when verbose is set to true.

This is the mount command that I am trying to get. I can get username and password in there, but only when using a .netrc file, and I have found no way to get the uid and gid into the command.

mount -t cifs -o username=myusername,password=mypasswd,uid=500,gid=499,rw //myserver.example.net/mysharename /the_mount_point/

So what I am looking for is the authoritative syntax for passing these options through docker-volume-netshare.

社区高分解答

原帖链接 · dmaj · CC BY-SA 4.0

A little bit late ... But here is the solution:

docker volume create \
     --driver local \
     --opt type=cifs \
     --opt device=//server.domain/path/to/share \
     --opt o=addr=server.domain,username=myuser,password=mypw,file_mode=0777,dir_mode=0777 \
     --name myvolume

In some situations the DNS-name did not work, this has been fixed in this PR and now domain names can be used by adding addr in the CIFS options. Using the option "credentials" instead of "username" an "password" did not work for me. I'm getting always the error "No username specified". From the shell (mount -t cifs //server/path -o credentials=/etc/cifs.cred /tmp/mnt) it works fine.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-09-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。