- I use vieux/sshfs to create a volume
docker plugin install --grant-all-permissions vieux/sshfs docker volume create -d vieux/sshfs -o sshcmd=usfo@192.168.1.1:/swarm-study/web/data -o password='123' sshvolume
- I create a user on container :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
- and use usfo users run apache
apache2.conf:
User usfo Group usfo
- use this command run container
docker run -itd -p 80:80 --mount type=volume,source=sshvolume,destination=/swarm-data debian2
- and I'm having trouble , only root users can access , usfo users can't not
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
- Try not using vieux / sshfs , Is work! , But i have to use 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 Version: 17.09.1-ce
debian 9