Running a docker-compose “Getting Started” example

2019-03-09 20:03发布

I am absolutely new to Docker. I followed steps described in Docker Compose's "Getting Started" tutorial:

  1. Install Docker Toolbox
  2. Start Docker Quickstart Terminal
  3. Add project files
  4. Run docker-compose up command

And I got following error:

ERROR: for web  Cannot create container for service web: Invalid bind mount spec "D:\\Projects\\composetest:/code:rw": Invalid volume specification: 'D:\Projects\composetest:/code:rw'
[31mERROR[0m: Encountered errors while bringing up the project.

docker-compose.yml:

version: '2'
services:
  web:
    build: .
    ports:
     - "5000:5000"
    volumes:
     - .:/code:rw
  redis:
    image: "redis:alpine"

Project structure:

D:\Projects\composetest
  ├── app.py
  ├── docker-compose.yml
  ├── Dockerfile
  └── requirements.txt

My configuration:

  1. Windows 10 Single Language
  2. Docker Toolbox 1.12.5

Why does it happen? Is there some workaround?

1条回答
干净又极端
2楼-- · 2019-03-09 20:12

I found the solution. The problem was I didn't set the environment variable COMPOSE_CONVERT_WINDOWS_PATHS. It is described in the CLI variables doc.

So, if this problem exists, you should create new Windows environment variable called COMPOSE_CONVERT_WINDOWS_PATHS and set it to 1. Or you can create .env file in the path docker-compose.yml is placed with following content:

 COMPOSE_CONVERT_WINDOWS_PATHS=1

It will solve this problem.

查看更多
登录 后发表回答