拒绝Docker容器访问NFS共享的权限-Docker Compose
我在使用Docker Compose将WD MyCloud EX2 NAS装载为Nextcloud和MariaDB容器组合的NFS共享时遇到问题。当我运行拒绝Docker容器访问NFS共享的权限-Docker Compose,docker,containers,nfs,Docker,Containers,Nfs,我在使用Docker Compose将WD MyCloud EX2 NAS装载为Nextcloud和MariaDB容器组合的NFS共享时遇到问题。当我运行docker compose up-d时,我得到的错误如下: Creating nextcloud_app_1 ... error ERROR: for nextcloud_app_1 Cannot create container for service app: b"error while mounting volume with op
docker compose up-d
时,我得到的错误如下:
Creating nextcloud_app_1 ... error
ERROR: for nextcloud_app_1 Cannot create container for service app: b"error while mounting volume with options: type='nfs' device=':/mnt/HD/HD_a/nextcloud' o='addr=192.168.1.73,rw': permission denied"
ERROR: for app Cannot create container for service app: b"error while mounting volume with options: type='nfs' device=':/mnt/HD/HD_a/nextcloud' o='addr=192.168.1.73,rw': permission denied"
ERROR: Encountered errors while bringing up the project.
这是docker compose.yml(所有敏感信息均替换为
):
然后,我用exportfs-a
没有更改-docker compose抛出相同的错误。我正在删除所有容器和图像,并在每次尝试构建时重新下载图像
我已经阅读了类似的问题,并做了我能想到的一切。我也知道这是一个容器问题,因为我可以从命令行非常愉快地访问NFS共享,这要感谢我在/etc/fstabs
中的设置
我还应该在这里做什么?尝试使用命令行ini nextcloud文件夹“ls-l/var/www/html”进行检查,请参阅可以访问它的组和用户我通过删除NAS盒的
/etc/exports
文件中的anonuid=501,anongid=1000
条目对其进行了修复,并且我还设法输入了错误的IP-NAS盒没有授予对试图与其连接的Ubuntu计算机的访问权限。在我们的例子中,我们正在安装nfs在docker主机上本地装载卷,然后在容器中装载文件夹
我们使用oracle linux 7运行,并启用SElinux。
我们通过在fs_mntops块的/etc/fstab中添加以下参数进行了修复(请参阅):
Version: '2'
volumes:
nextcloud:
driver: local
driver_opts:
type: nfs
o: addr=192.168.1.73,rw
device: ":/mnt/HD/HD_a/nextcloud"
db:
services:
db:
image: mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: always
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=<****>
- MYSQL_PASSWORD=<****>
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- NEXTCLOUD_ADMIN_USER=<****>
- NEXTCLOUD_ADMIN_PASSWORD=<****>
app:
image: nextcloud
ports:
- 8080:80
links:
- db
volumes:
- nextcloud:/var/www/html
restart: always
"/nfs/nextcloud" 192.168.1.73(rw,no_root_squash,sync,no_wdelay,insecure_locks,insecure,no_subtree_check,anonuid=501,anongid=1000)
"/nfs/Public" 192.168.1.73(rw,no_root_squash,sync,no_wdelay,insecure_locks,insecure,no_subtree_check,anonuid=501,anongid=1000)
defaults,context="system_u:object_r:svirt_sandbox_file_t:s0"