docker vieux / sshfs权限被拒绝

问题描述 投票:4回答:1
  1. 我使用vieux / sshfs来创建一个卷
docker plugin install --grant-all-permissions vieux/sshfs
docker volume create  -d vieux/sshfs   -o [email protected]:/swarm-study/web/data  -o password='123' sshvolume
  1. 我在容器上创建了一个用户:usfo Dockerfile:
FROM debian
COPY sources.list /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y apache2
RUN apt-get install -y php7.0 php7.0-mysql
COPY apache2.conf /etc/apache2/apache2.conf

RUN groupadd -g 1000 usfo
RUN useradd  -u 1000 -g 1000 usfo

COPY index.php /var/www/html/index.php
RUN mkdir /autorun
COPY autorun.sh /autorun/autorun.sh
RUN chmod 755 /autorun/autorun.sh
RUN mkdir /html-data
CMD ./autorun/autorun.sh
  1. 并使用usfo用户运行apache apache2.conf:
User usfo
Group usfo
  1. 使用此命令运行容器
docker run -itd -p 80:80 --mount type=volume,source=sshvolume,destination=/swarm-data debian2
  1. 而且我遇到了麻烦,只有root用户可以访问,usfo用户不能没有
root@e3ca660f3a8d:/# su root
root@e3ca660f3a8d:/# ls -l /swarm-data
total 8
-rw-r--r-- 1 usfo usfo 1136 Dec 26 02:37 Desktop.rar
-rw-r--r-- 1 usfo usfo    7 Dec 26 02:18 a.txt

root@e3ca660f3a8d:/# ls -l / | grep swarm-data
drwxr-x---   1 usfo usfo 4096 Dec 26 02:37 swarm-data
root@e3ca660f3a8d:/# su usfo
$ ls -l / |grep swarm-data
ls: cannot access '/swarm-data': Permission denied
d?????????   ? ?    ?       ?            ? swarm-data
  1. 尝试不使用vieux / sshfs,工作! ,但我必须使用vieux / sshfs !!
docker run -itd -p 80:80 -v  /swarm-study/web/data:/swarm-data debian2

root@d678cdb273c8:/# su usfo
$ ls -l / | grep swarm-data
drwxr-x---   2 usfo usfo 4096 Dec 26 10:54 swarm-data

docker版本:17.09.1-这个

debian 9

docker sshfs
1个回答
0
投票

报价:https://github.com/vieux/docker-volume-sshfs/issues/17 谢谢@koenlek

事实证明,您需要使用sshfs的-o allow_other选项。

docker volume create  -d vieux/sshfs   -o [email protected]:/swarm-study/web/data  -o allow_other -o password='123' sshvolume
root@f5132a8f4b84:/# su usfo
$ ls -l / | grep swarm-data
drwxr-x---   1 usfo usfo 4096 Dec 26 10:54 swarm-data
© www.soinside.com 2019 - 2024. All rights reserved.