将配置文件装入容器时出错

Dan*_*iel 7 windows docker docker-compose

编辑:我在窗户上.

我正在尝试使用docker-compose.我知道我应该使用Dockerfile将文件复制到容器中,但是我想通过挂载文件来解决它,因为这对我的实验来说更容易.我还想把这作为一个关于这个问题的学习经验.

docker-compose.yml看起来像这样:

version: "3"
services:
  webserver:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./webapp.conf:/etc/nginx/conf.d/default.conf
  webapp:
    image: wordpress:php7.1-fpm
Run Code Online (Sandbox Code Playgroud)

运行时docker-compose up我看到以下错误消息:

PS C:\Users\daniel\Documents\Docker> docker-compose up
Removing docker_webserver_1
Recreating ed1b21e6939c_docker_webserver_1
docker_webapp_1 is up-to-date

ERROR: for webserver  Cannot start service webserver: error while creating mount source path '/C/Users/daniel/Documents/Docker/webapp.conf': mkdir /C/Users/daniel/Documents: permission denied
ERROR: Encountered errors while bringing up the project.
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么.

h3x*_*eam 8

(几分钟前我添加了同样的问题.)

确保允许您的docker挂载目录 C:\Users\[redacted]\Documents\Docker

组态

在Windows客户端中,您可以将docker配置为允许在特定驱动器上进行读/写.这应该可以解决您的权限问题.

在此输入图像描述

已配置?

在我的情况下,它已被选中.我取消选中并再次检查驱动器.应用"更改".它提示我输入我的Windows密码(已更改),而且安装程序再次运行.

  • 当您尝试在Windows上安装的文件夹没有正确的权限设置时,您还会收到权限被拒绝的错误。就我而言,我必须编辑源文件夹的权限,以便计算机中的Users组可以访问它。 (3认同)