简体   繁体   English

Docker容器未显示已装载的卷-访问问题

[英]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)

The issue is the volume is being mounted to the container but from the container it is not having any acces to the mounted volume. 问题是该卷正被安装到容器上,但是从容器上它并没有访问已安装的卷。 I can cd to /opt/webapp/bin but i can not ls /opt/webapp/bin. 我可以CD到/ opt / webapp / bin,但不能ls / opt / webapp / bin。

Please suggest how it can be fixed. 请提出如何解决。 The host mount has all files having 777 permission. 主机装载中包含所有具有777权限的文件。

Docker processes have the svirt_lxc_net_t default type. Docker进程具有svirt_lxc_net_t默认类型。 By default these processes are not allowed to access your content in /var , /root and /home . 默认情况下,这些过程都不允许访问在/ var内容,/根/ home。

You have specify a suitable type label for your host folder, to allow the container processes to access the content. 您已经为主机文件夹指定了合适的类型标签,以允许容器进程访问内容。 You can do this by giving the $PWD/webapp folder the type label svirt_sandbox_file_t . 您可以通过为$ PWD / webapp文件夹指定类型标签svirt_sandbox_file_t来实现此目的

chcon -Rt svirt_sandbox_file_t $PWD/webapp

After this, you can access the folder from within the container. 之后,您可以从容器中访问文件夹。 Read more about it in Dan Walsh's article - Bringing new security features to Docker Dan Walsh的文章中了解更多相关内容-为Docker带来新的安全功能

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

相关问题 由docker容器写入已装入卷的文件的所有权 - ownership of files that are written by the docker container to mounted volume 在 Ubuntu 上运行 docker:安装的主机卷不可从容器写入 - Running docker on Ubuntu: mounted host volume is not writable from container 安装到linux docker容器卷的Windows文件夹不显示所有文件夹 - Windows folder mounted to linux docker container volume not displaying all folders 为什么我安装的docker卷文件会变成容器内的文件夹? - Why are my mounted docker volume files turning into folders inside the container? Docker:已安装卷的权限 - Docker: Permissions for a mounted volume docker 容器的用户权限是否会影响主机对 docker-compose.yml 中挂载卷的权限? - Can user privilege of docker container impact permission of host machine on mounted volume in docker-compose.yml? 在主机上更改已装入卷中的文件时,未在docker容器中触发文件系统事件 - File system events not triggered in docker container when files in mounted volume are changed on the host Docker 节点在挂载的卷上找不到文件 - Docker node cannot find file on mounted volume Docker挂载卷不跟踪Nginx日志文件 - Docker mounted volume not tracking nginx log files Docker Jetty 应用程序无权限写入已安装的卷 - Docker Jetty app no permission writing on mounted volume
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM