[英]ownership of files that are written by the docker container to mounted volume
[英]Docker container not showing volume mounted - Access issue
root@centdev01$ grep -e CMD -e RUN Dockerfile
RUN apt-get update
RUN apt-get -y install ruby ruby-dev build-essential redis-tools
RUN gem install --no-rdoc --no-ri sinatra json redis
RUN mkdir -p /opt/webapp
RUN chmod 777 /opt/webapp
CMD ["/opt/webapp/bin/webapp"]
root@centdev01$ docker build -t "alok87/sinatra" .
root@centdev01$ docker run -d -p 80 --name ubunsin10 -v $PWD/webapp:/opt/webapp alok87/sinatra
25ekgjalgjal25rkg
root@centdev01$ docker logs ubunsin10
/opt/webapp/bin/webapp: Permission Denied - /opt/webapp/bin/webapp ( Errno:EACCESS)
問題是該卷正被安裝到容器上,但是從容器上它並沒有訪問已安裝的卷。 我可以CD到/ opt / webapp / bin,但不能ls / opt / webapp / bin。
請提出如何解決。 主機裝載中包含所有具有777權限的文件。
Docker進程具有svirt_lxc_net_t默認類型。 默認情況下,這些過程都不允許訪問在/ var內容,/根和/ home。
您已經為主機文件夾指定了合適的類型標簽,以允許容器進程訪問內容。 您可以通過為$ PWD / webapp文件夾指定類型標簽svirt_sandbox_file_t來實現此目的 。
chcon -Rt svirt_sandbox_file_t $PWD/webapp
之后,您可以從容器中訪問文件夾。 在Dan Walsh的文章中了解更多相關內容-為Docker帶來新的安全功能
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.