在 Windows 上使用 Docker-Compose 拒绝权限

Ele*_*gie 3 windows docker docker-compose

我目前正在学习 Docker,这本书是“使用 Docker”。在第 5 章中,作者从 using 切换docker run到 using docker compose,这permission denied在我的测试应用程序中产生了错误。有什么我可以做的吗?

我用:

  • Windows 10 家庭版,带有 Docker 工具箱
  • Docker 版本是 1.12.0
  • Docker Compose 版本是1.8.0, buildd988a55

DockerFile :

FROM python:3.4

RUN groupadd -r uwsgi && useradd -r -g uwsgi uwsgi
RUN pip install Flask==0.10.1 uWSGI==2.0.8
WORKDIR /app
COPY app /app
COPY cmd.sh /

EXPOSE 9090 9191
USER uwsgi

CMD ["/cmd.sh"]
Run Code Online (Sandbox Code Playgroud)

docker-compose.yml:

identidock:
  build: .
  ports:
    - "5000:5000"
  environment:
    ENV: DEV
  volumes:
    - ./app:/app
Run Code Online (Sandbox Code Playgroud)

根据C:/Users/MyUserName工具箱的要求,该应用程序位于 下,以使共享卷正常工作。

工作 docker 命令启动容器和 Web 服务器,并将其成功公开给我的 Windows 主机:

docker run -e "ENV=DEV" -p 5000:5000 identidock
Run Code Online (Sandbox Code Playgroud)

该docker-compose up命令失败,以下消息:

Starting identidock_identidock_1

ERROR: for identidock  Cannot start service identidock: oci runtime error: exec: "/cmd.sh": permission denied
?[31mERROR?[0m: Encountered errors while bringing up the project.
Run Code Online (Sandbox Code Playgroud)

DAX*_*lic 6

Try adding

RUN chmod +x /cmd.sh
Run Code Online (Sandbox Code Playgroud)

to your Dockerfile after

COPY cmd.sh /  
Run Code Online (Sandbox Code Playgroud)

According to that issue it seems that the docker client sets the needed exec permission for the file while docker compose does not

It may be that the docker client sets the executable bit for all files, where as Compose does not (yet).