compose: docker-compose fails with invalid volume specification

Description of the issue

docker-compose fails with invalid volume specification

Context information (for bug reports)

Output of “docker-compose version” PS C:\temp> docker-compose --version docker-compose version 1.20.1, build 5d8c71b2

Output of “docker version” PS C:\temp> docker --version Docker version 18.03.0-ce, build 0520e24

Output of “docker-compose config” PS C:\temp> docker-compose config networks: default: external: true name: nat services: test: image: microsoft/windowsservercore volumes: - /c/temp:/data:rw version: ‘3.6’

Steps to reproduce the issue

PS C:\temp> docker-compose -f c:\temp\docker-compose.yml up --build Creating temp_test_1 … error

ERROR: for temp_test_1 Cannot create container for service test: invalid volume specification: ‘/c/temp:/data:rw’

ERROR: for test Cannot create container for service test: invalid volume specification: ‘/c/temp:/data:rw’ ERROR: Encountered errors while bringing up the project.

Observed result

Expected to build image with volume mapped.

Expected result

Error: invalid volume specification

Stacktrace / full error message

[18:26:01.536][WindowsDaemon ][Info ] debug: FIXME: Got an API for which error does not match any expected type!!!: invalid volume specification: ‘/c/temp:/data:rw’ github.com/docker/docker/volume.errInvalidSpec /go/src/github.com/docker/docker/volume/volume.go:230 github.com/docker/docker/volume.windowsSplitRawSpec /go/src/github.com/docker/docker/volume/windows_parser.go:87 github.com/docker/docker/volume.(*windowsParser).parseMountRaw /go/src/github.com/docker/docker/volume/windows_parser.go:305 github.com/docker/docker/volume.(*windowsParser).ParseMountRaw /go/src/github.com/docker/docker/volume/windows_parser.go:301 github.com/docker/docker/daemon.(*Daemon).registerMountPoints /go/src/github.com/docker/docker/daemon/volumes.go:146 github.com/docker/docker/daemon.(*Daemon).setHostConfig /go/src/github.com/docker/docker/daemon/container.go:215 github.com/docker/docker/daemon.(*Daemon).create /go/src/github.com/docker/docker/daemon/create.go:173 github.com/docker/docker/daemon.(*Daemon).containerCreate /go/src/github.com/docker/docker/daemon/create.go:75 github.com/docker/docker/daemon.(*Daemon).ContainerCreate /go/src/github.com/docker/docker/daemon/create.go:34 github.com/docker/docker/api/server/router/container.(*containerRouter).postContainersCreate /go/src/github.com/docker/docker/api/server/router/container/container_routes.go:468 github.com/docker/docker/api/server/router/container.(*containerRouter).(github.com/docker/docker/api/server/router/container.postContainersCreate)-fm /go/src/github.com/docker/docker/api/server/router/container/container.go:47 github.com/docker/docker/api/server/middleware.ExperimentalMiddleware.WrapHandler.func1 /go/src/github.com/docker/docker/api/server/middleware/experimental.go:27 github.com/docker/docker/api/server/middleware.VersionMiddleware.WrapHandler.func1 /go/src/github.com/docker/docker/api/server/middleware/version.go:62 github.com/docker/docker/pkg/authorization.(*Middleware).WrapHandler.func1 /go/src/github.com/docker/docker/pkg/authorization/middleware.go:59 github.com/docker/docker/api/server/middleware.DebugRequestMiddleware.func1 /go/src/github.com/docker/docker/api/server/middleware/debug.go:53 github.com/docker/docker/api/server.(*Server).makeHTTPHandler.func1 /go/src/github.com/docker/docker/api/server/server.go:137 net/http.HandlerFunc.ServeHTTP /usr/local/go/src/net/http/server.go:1918 github.com/docker/docker/vendor/github.com/gorilla/mux.(*Router).ServeHTTP /go/src/github.com/docker/docker/vendor/github.com/gorilla/mux/mux.go:103 github.com/docker/docker/api/server.(*routerSwapper).ServeHTTP /go/src/github.com/docker/docker/api/server/router_swapper.go:29 net/http.serverHandler.ServeHTTP /usr/local/go/src/net/http/server.go:2619 net/http.(*conn).serve /usr/local/go/src/net/http/server.go:1801 runtime.goexit /usr/local/go/src/runtime/asm_amd64.s:2337 [module=api error_type=*errors.fundamental](if applicable)


## Additional information

OS version / distribution, `docker-compose` install method, etc.
Windows 10 Pro
Installed with Docker for Windows

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 12
  • Comments: 30

Commits related to this issue

Most upvoted comments

Oh, sorry, did you actually write your mount like this? /c/temp:/data:rw If so, you need to rewrite it correctly: C:\temp:/data:rw

I’m facing the same issue for docker-compose up

Okay, so it seems to work after all, kind of. I am using Windows containers, and they are bit different in every possible way…

If I create a volume in Dockerfile:

FROM microsoft/nanoserver
SHELL ["powershell.exe", "-Command"]
VOLUME C:/volume

And then use it in docker-compose.yaml:

version: "3"
services:
  localnano:
    build: .
    volumes:
      - testvolume:C:/volume
volumes:
  testvolume:

The files do start to appear in here:

PS> ls (docker volume inspect composer_testvolume --format '{{.Mountpoint}}')

BUT I cannot change the location freely, because of this: https://github.com/sixeyed/docker-windows-kb/blob/master/1.13/limitations/volumes/driver-opts-not-supported.md

(I think it would really help if someone would re-write the docker-compose tutorial to be Windows compliant, or create a separate “Windows Errata” to list all the tiny differences…)

(And it would be really nice if docker-compose would say something like “the Windows platform does not support volume options” instead of “invalid volume specification”…)

Path is probably not converted to unix style. Since 1.9.0, Windows paths are not automatically converted (eg. C:\Users to /c/Users).

Solution: Set COMPOSE_CONVERT_WINDOWS_PATHS environment variable to “true” or “1”.

My observation made on mongo:windowsservercore is, that if you use windows container, you need to pass volume sign of container OS

services:
  mongo:
    image: mongo
    hostname: mongo-server
    ports:
      - 27017:27017
    volumes:
      - d:/data:c:/data/db

missing c: was the reason I had invalid volume specification.

I’m using the latest version of Docker Desktop 2.1.0.6.

It seems if we specify the volume as following: .\src\Health.Website:C:\src, we need to ensure the environment variable COMPOSE_CONVERT_WINDOWS_PATHS is set to false/0. It works fine for me.

Even linux user get the same issue…

Same problem over here.

Had the same issue trying to create linux container on windows machine using docker compose. I am using Docker Desktop.
Realized that my Docker Desktop was set to use Windows containers. Switching it to Linux containers fixed the issue. (Just right click on the Docker Desktop icon on the taskbar).

Hope this helps

Same problem here, OS is Win10 and software is the newest version.

I think this is something that used to work when Docker for Windows had the “Shared Drives” setup screen: d4w-shared-drives That setup screen does not exist anymore.

Anyhow, “docker run” works fine with volumes. It is the “docker-compose up” that breaks down with “invalid volume specification” error.

I was able to solve this by changing

volumes:
  - .:\code

to

volumes:
  - .:c:\code

It’s easy to forget how the file systems different if you don’t switch between them often.

I have tried just about every possible combination. The volume mapping works correctly when using just docker.