4

EDIT: The problem is the COMPOSE_CONVERT_WINDOWS_PATHS environment variable isn't getting set. I tried adding it to the Dockerfile and to a .env file but its not being set. I can't set any new environment variables. Its like its building it from a cached Dockerfile.

I was running docker-composer up after deleting the container, but this didn't recreate a new container, even when adding --force-recreate, it created the container from the old Dockerfile. So I ran docker build ./ instead, and it built a new container, it reinstalled all the packages, and it said that it was setting the new environment variables, but in the finished container, when I check kinematic, I see the new environment variables aren't set. But all of the old environment variables that were set when I built the container for the first time, they're all set. I don't know why this is happening, why I can't create a new container from the updated Dockerfile.

I've found a number of threads about this error, it happens when trying to mount a volume in Windows docker-tools. When I run docker-compose up, I get this error:

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

In the docker-compose file I have this:

    volumes:
        - ./:/app

I tried setting this environment variable:

COMPOSE_CONVERT_WINDOWS_PATHS=1

to 1, as that worked for some people in another thread but its not working in this case. I tried adding an absolute path in linux like format:

    volumes:
        - /c/path/to/project:/app

and I get this error:

ERROR: for web  Cannot create container for service web: create \c\path\to\project: "\\c\\path\\to\\project" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed

Notice it reversed the forward slashes. Changing:

ENV COMPOSE_CONVERT_WINDOWS_PATHS=0

to 0 like that didn't change anything.

If I give a Windows format absolute directory, I get the first error again. Both of those errors, I get them if I point to a directory that doesn't exist.

Has anyone here figured out a way to resolve this?

Horse O'Houlihan
  • 1,659
  • 4
  • 14
  • 29
  • When after setting the COMPOSE_CONVERT_WINDOWS_PATHS environment variable I'd got the same error, I used /c/path/to/project:/app in Docker Terminal and it worked! – Eugenia Ozirna Jan 12 '17 at 19:50
  • Possible duplicate of [docker invalid characters for local volume name](https://stackoverflow.com/questions/41394822/docker-invalid-characters-for-local-volume-name) – kenorb Mar 11 '19 at 22:18

3 Answers3

3

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

..

cat >.env
COMPOSE_CONVERT_WINDOWS_PATHS=1
Xelian
  • 16,680
  • 25
  • 99
  • 152
1

It looks like your COMPOSE_CONVERT_WINDOWS_PATHS=1 environment variable is not read by docker cli (powershell). you can try to run Get-childItem Env: command from your powershell console to get the list of environment variable which has been set in your powershell console. the output is like below:

Name                           Value
----                           -----
COMPOSE_CONVERT_WINDOWS_PATHS  1
COMSPEC                        C:\WINDOWS\system32\cmd.exe
DOCKER_CERT_PATH               C:\Users\devsa\.docker\machine\machines\default
DOCKER_HOST                    tcp://192.168.99.100:2376
DOCKER_TLS_VERIFY              1
...

If you don't see the COMPOSE_CONVERT_WINDOWS_PATHS=1 variable in your powershell console, it means the variable has not been set yet. To set the environment variable via powershell console, try this command:

$env:COMPOSE_CONVERT_WINDOWS_PATHS=1

it will set the environment variable in your power shell console check this powershell documentation for full documentation. Try to run the Get-childItem Env: command again to check whether the variable has been already set or not. if the variable has been set, you can try to run docker-compose up -d again.

Bhanu
  • 351
  • 2
  • 15
0

After setting the environment variable to COMPOSE_CONVERT_WINDOWS_PATHS=1 try below setting in docker-compose

- ./app-demo:/dockermount under volumes

It worked for me

user1775015
  • 179
  • 1
  • 6