背景
我想在Windows 8上运行一个Docker Compose应用程序。该应用程序已经在Ubuntu 16.04下制作完成,并在其上完美运行。
这个Docker Compose会运行:
- nginx
- php-fpm
这两个容器使用卷。
文件
我的.env
文件:
COMPOSE_CONVERT_WINDOWS_PATHS=1
APPLICATION_PATH=//C/Users/my_user/Documents/Development/my_application
我的
docker-compose.yml
文件:version: '2'
services:
web:
build: ../application-web/
ports:
- "80:80"
tty: true
# Add a volume to link php code on the host and inside the container
volumes:
- ${APPLICATION_PATH}:/usr/share/nginx/html/application
- ${APPLICATION_PATH}/docker_files/docker-assistant:/usr/share/nginx/html/assistant
# Add hostnames to allow devs to call special url to open sites
extra_hosts:
- "localhost:127.0.0.1"
- "assistant.docker:127.0.0.1"
- "application.dev:127.0.0.1"
depends_on:
- custom-php
links:
- custom-php:custom-php
custom-php:
build: ../application-php/
ports:
- "50:50"
volumes:
- ${APPLICATION_PATH}:/usr/share/nginx/html/application
- ${APPLICATION_PATH}/docker_files/docker-assistant:/usr/share/nginx/html/assistant
问题
当我运行docker-compose up
时,一切正常。容器启动。
但是当我尝试在我的浏览器中访问http://192.168.99.100时,我得到了一个403错误。
我的调查显示nginx和php容器中没有挂载的卷:
docker exec -it compose_web_1 bash
ls -la /usr/share/nginx/html/assistant/
展示
drwxr.xr.x 2 root root 80 May 18 15:30 .
drwxr.xr.x 2 root root 4096 May 18 16:10 ..
看起来Docker不能挂载卷。为什么?
其他信息
- I am using the Docker Toolbox: https://www.docker.com/products/docker-toolbox
- I know that's the good IP address because when I try to reach it in my web browser, I see my nginx container displaying logs.
- The environment variable
APPLICATION_PATH
set as//C:/Users/my_user/Documents/Development/my_application
cannot work because Docker use the ":" character as separator for volume declaration:ERROR: Volume //C:/Users/my_user/Documents/Development/my_application://C:/Users/my_user/Documents/Development/my_application has incorrect format, should be external:internal[:mode]
It's not a nginx problem because when I create an
index.phtml
file in the folder, I am able to run it:<?php echo 'Hello world!';
APPLICATION_PATH=C:/Users/my_user/Documents/Development/my_application
)吗?也许这个链接会有所帮助。此外,请验证IP地址。 - Holger