Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compose on windows, machine on remote linux: incorrect volume escaping #4253

Closed
howardjones opened this issue Dec 16, 2016 · 9 comments
Closed

Comments

@howardjones
Copy link

I have a docker host running on esxi, created with docker-machine. I have Docker for Windows installed locally to get docker-compose and docker-machine on my Windows desktop. Then I can use docker-machine env to set the relevant environment for compose to work.

That all worked fine until I wanted to add an haproxy container from dockercloud, which needs to talk to the host. Their docs say to add this to the docker-compose.yml for the LB.

volumes:
  - /var/run/docker.sock:/var/run/docker.sock

so that the LB can find the web servers that it is supposed to be balancing.

However when I run docker-compose up on my Windows desktop, I get this error:

ERROR: for lb  Cannot create container for service lb: b'create \\var\\run\\docker.sock: "\\\\var\\\\run\\\\docker.sock" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed'
ERROR: Encountered errors while bringing up the project.

Note there are backslashes here, not forward slashes. So I think that something in docker-compose is incorrectly translating the paths to Windows paths, and then looking at them on Linux, seeing they aren't paths, and complaining that they aren't valid volume names, which is true but unhelpful.

Is there a magic switch to say that the host is not the local windows system and side-step this?

@shin-
Copy link

shin- commented Dec 16, 2016

I'm assuming you're running those commands from Powershell. Please try running the following:

Remove-Item Env:\COMPOSE_CONVERT_WINDOWS_PATHS
docker-compose up

@airtonix
Copy link

@shin- doing that will cause other errors. see: #4240

@howardjones
Copy link
Author

howardjones commented Dec 17, 2016

No, this is from the windows command prompt (actually, CMD in ConEmu). But the gist is to unset the environment variable? or set it to 0? From #4240, it seems like 0 is the better choice.

@whyleee
Copy link

whyleee commented Aug 19, 2017

The solution from #4240 helped me: $env:COMPOSE_CONVERT_WINDOWS_PATHS=1

@kkm000
Copy link

kkm000 commented Jun 29, 2018

@shin- commented on Dec 16, 2016:

I'm assuming you're running those commands from Powershell. Please try running the following:

Remove-Item Env:\COMPOSE_CONVERT_WINDOWS_PATHS

Actually, exactly as @whyleee suggested above, its exactly the opposite. I got exactly the same error, and unsuccessfully tried setting COMPOSE_CONVERT_WINDOWS_PATHS to 0 or to remove it, but it never occurred to me to try the opposite thing: set "convert Windows paths" to prevent the conversion of Windows paths. The documentation clearly must be updated. Especially given this issue is as old as Moses, and so many people hit it. If it's helpful, my server is on a remote single-board very headless Linux machine, but the client is on Windows. I understand the setting name and behavior may make sense somewhere internally, but to the user it is utterly confusing, really! It's doing the exact opposite of what it says it's doing.

Is it possible to reflect this in the documentation somehow please?

Here's my repro with the latest v1.22.0-rc1. The following yaml clause for a bind mount

version: '3'
 [... snip...]
    volumes:
      - "/share/Storage/.gitpubkeys:/mnt/keys:ro"

results in an unsuccessful compose up unless COMPOSE_CONVERT_WINDOWS_PATHS is set to 1:

C:\projects\docker-confman>docker-compose --version && docker version
docker-compose version 1.22.0-rc1, build e7de1bc3
Client:
 Version:      18.03.1-ce
 API version:  1.31 (downgraded from 1.37)
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:12:48 2018
 OS/Arch:      windows/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      17.07.0-ce
  API version:  1.31 (minimum version 1.12)
  Go version:   go1.8.3
  Git commit:   fd7dc00
  Built:        Tue Mar 13 11:26:10 2018
  OS/Arch:      linux/arm
  Experimental: false

C:\projects\docker-confman>set COMPOSE_CONVERT_WINDOWS_PATHS=
C:\projects\docker-confman>docker-compose up
Creating confman-server ... error

ERROR: for confman-server  Cannot create container for service confman-server: create \share\Storage\.gitpubkeys: "\\share\\Storage\\.gitpubkeys" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path

ERROR: for confman-server  Cannot create container for service confman-server: create \share\Storage\.gitpubkeys: "\\share\\Storage\\.gitpubkeys" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path
ERROR: Encountered errors while bringing up the project.

C:\projects\docker-confman>set COMPOSE_CONVERT_WINDOWS_PATHS=1

C:\projects\docker-confman>docker-compose up
Creating confman-server ... done
Gracefully stopping... (press Ctrl+C again to force)
Stopping confman-server ... done

@stale
Copy link

stale bot commented Oct 9, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 9, 2019
@stale
Copy link

stale bot commented Oct 16, 2019

This issue has been automatically closed because it had not recent activity during the stale period.

@stale stale bot closed this as completed Oct 16, 2019
@surfaceowl
Copy link

bump - this should still be open

@AniketKariya
Copy link

any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants