Docker Community Forums

Share and learn in the Docker community.

Cannot create container for service web: invalid volume specification:

I am tired of researching the solution of this error and trying the same solutions all the time. Although I have created a very simple compose file, why can’t I still run it. I am encountering this hateful mistake?

I tried converting paths, in any case I get the same error.

docker-compose.yml

version: "3.5"

services:
  web:
    image: nginx:latest
    ports:
      - "8080:80"
    volumes:
      - ./code:/code
      - ./site.conf:/etc/nginx/conf.d/site.conf

.env

COMPOSE_CONVERT_WINDOWS_PATHS=1

site.conf

server {
    index index.html;
    server_name php-docker.local;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /code;
}

Full error output following; (I’m tried; powershell, cmd, git-bash)

Creating php-server_web_1 ... error                                                                                     
ERROR: for php-server_web_1  Cannot create container for service web: invalid volume specification: '/c/_my-mind/_codes/docker-compose-tests/php-server/code:/code:rw'

ERROR: for web  Cannot create container for service web: invalid volume specification: '/c/_my-mind/_codes/docker-compose-tests/php-server/code:/code:rw'
ERROR: Encountered errors while bringing up the project.

My machine info

WindowsProductName WindowsVersion OsHardwareAbstractionLayer
------------------ -------------- --------------------------
Windows 10 Pro     1903           10.0.18362.752

My docker version info

Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:23:10 2020
 OS/Arch:           windows/amd64
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.24)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:37:20 2020
  OS/Arch:          windows/amd64
  Experimental:     true

My docker compose version

docker-compose version 1.25.4, build 8d51620a

How do we solve this problem?