简体   繁体   English

Docker 在 nfs 挂载上运行导致无法复制和无法 chown

[英]Docker run on nfs mount causes fail to copy and fail to chown

I have a nfs share which I can mount without issues but docker doesn't want a bar of it :/我有一个 nfs 共享,我可以毫无问题地安装它,但 docker 不想要它:/

If I don't include the nfs volumes it installs fine.如果我不包括 nfs 卷,它安装得很好。

I've tried with the permissions on the nfs share set to "chmod 777" and "chown nobody:nobody".我已经尝试将 nfs 共享的权限设置为“chmod 777”和“chown nobody:nobody”。

I can connect to it from my mac and write to the nfs share.我可以从我的 mac 连接到它并写入 nfs 共享。

 > docker volume create --driver local \
    --opt type=nfs4 \
    --opt o=addr=192.168.1.48,rw \
    --opt device=:/mnt/tank/virtualisation/database \
    database
> docker volume inspect database
[
    {
        "CreatedAt": "2019-05-14T17:14:54+10:00",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/var/lib/docker/volumes/database/_data",
        "Name": "database",
        "Options": {
            "device": ":/mnt/tank/virtualisation/database",
            "o": "addr=192.168.1.48,rw",
            "type": "nfs4"
        },
        "Scope": "local"
    }
]
> docker run --name mysql -v database:/var/lib/mysql -v database:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=root -d percona:ps-8


docker: Error response from daemon: failed to copy file info for /var/lib/docker/volumes/database/_data: failed to chown /var/li
b/docker/volumes/database/_data: lchown /var/lib/docker/volumes/database/_data: operation not permitted.

System details.系统详情。

Server (FreeNAS)服务器 (FreeNAS)

> showmount -e 192.168.1.48
Exports list on 192.168.1.48:
/mnt/tank/virtualisation/database  Everyone

Debian 9.9 VM with docker带有 docker 的 Debian 9.9 VM

> docker version
Client:
 Version:           18.09.6
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        481bc77
 Built:             Sat May  4 02:36:00 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.6
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       481bc77
  Built:            Sat May  4 01:59:36 2019
  OS/Arch:          linux/amd64
  Experimental:     false

I faced the same problem with a NFS share i need to mount as volume in an nginx container.我遇到了与 NFS 共享相同的问题,我需要在 nginx 容器中作为卷安装。

In my case adding no_root_squash as option for the NFS share solved the problem: this option causes root user/group of NFS client to be mapped to root user/group of the NFS server, as you can read eg here .在我的例子中,添加no_root_squash作为 NFS 共享的选项解决了这个问题:这个选项会导致 NFS 客户端的 root 用户/组被映射到 NFS 服务器的 root 用户/组,你可以在这里阅读。

So, finally my /etc/exports looks like this:所以,最后我的/etc/exports看起来像这样:

/tank/honey-files 172.29.6.0/16(rw,sync,no_subtree_check,no_root_squash)

and I can mount it into a container creating a volume我可以将它安装到创建卷的容器中

docker volume create honey-files --driver local --opt type=nfs --opt o=addr=172.29.6.200 --opt device=:/tank/honey-files

and using it with docker run / docker service create :并将其与docker run / docker service create


docker run --name nginx --rm -v honey-files:/usr/share/nginx/html -p 30001:80 nginx:latest
docker service create --name nginx -p 30002:80 --mount 'src=honey-files,target=/usr/share/nginx/html' nginx:latest

The question is very old, but... I hope this answer can help you!这个问题很老了,但是......我希望这个答案可以帮助你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM