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

Add environment variable to force windows parsing style of volume paths #5560

Merged
merged 1 commit into from
Jan 17, 2018

Conversation

shin-
Copy link

@shin- shin- commented Jan 11, 2018

Fixes #5371

Users can set COMPOSE_FORCE_WINDOWS_HOST=1 to parse volumes and normalize paths as if working from a WIndows host, even if Compose is running on a UNIX system.

@shin-
Copy link
Author

shin- commented Jan 11, 2018

cc @StefanScherer if you can give this a whirl, that'd be awesome!

@shin- shin- force-pushed the 5371-force-windows-volume-parsing branch from 495ed45 to 2fbec60 Compare January 11, 2018 01:11
@StefanScherer
Copy link
Member

Thanks. I compiled the Darwin binary, but I still see this error:

Without any environment variable:

$ ~/code/compose/dist/docker-compose-Darwin-x86_64 up
ERROR: Volume C:\\Users\\stefan\\.ssh:C:\\ssh has incorrect format, should be external:internal[:mode]

With COMPOSE_FORCE_WINDOWS_HOST=1

$ COMPOSE_FORCE_WINDOWS_HOST=1 ~/code/compose/dist/docker-compose-Darwin-x86_64 up
Creating composeissue5371_test_1 ... error

ERROR: for composeissue5371_test_1  Cannot create container for service test: invalid volume spec "C:\\\\ssh": invalid volume specification: 'C:\\ssh'

ERROR: for test  Cannot create container for service test: invalid volume spec "C:\\\\ssh": invalid volume specification: 'C:\\ssh'
ERROR: Encountered errors while bringing up the project.

I also tried a Windows build from inside the Win2016 VM, but I also see error, both with short and long variant and without and with the environment variable set.

C:\Users\stefan\code\dockerfiles-windows\compose-issue-5371>build\docker-compose-Windows-x86_64.exe up
Creating composeissue5371_test_1 ... error

ERROR: for composeissue5371_test_1  Cannot create container for service test: invalid volume spec "C:\\\\ssh": invalid volume specification: 'C:\\ssh'

ERROR: for test  Cannot create container for service test: invalid volume spec "C:\\\\ssh": invalid volume specification: 'C:\\ssh'
ERROR: Encountered errors while bringing up the project.

I think this should be solved without additional environment variables that the user has to define and know of. Instead docker-compose should recognise the Docker server platform.

@shin-
Copy link
Author

shin- commented Jan 11, 2018

Have you tried using single backslashes? In my tests the double slashes weren't necessary. The error you get from the server seems to indicate that as well.

I think this should be solved without additional environment variables that the user has to define and know of. Instead docker-compose should recognise the Docker server platform.

I considered it, but there are some architectural limitations that make this complicated. Specifically, it would mean docker-compose config could not be an offline operation anymore. We can reevaluate, but the environment variable is a good compromise in the meantime.

@StefanScherer
Copy link
Member

Woot woot!

$ COMPOSE_FORCE_WINDOWS_HOST=1 ~/code/compose/dist/docker-compose-Darwin-x86_64 up
Creating composeissue5371_test_1 ... done
Attaching to composeissue5371_test_1
test_1  | Microsoft Windows [Version 10.0.14393]
test_1  | (c) 2016 Microsoft Corporation. All rights reserved.
test_1  | 
test_1  | C:\>composeissue5371_test_1 exited with code 0

Oh and it works with docker-compose 1.18.0 as well

$ docker-compose up
Starting composeissue5371_test_1 ... done
Attaching to composeissue5371_test_1
test_1  | Microsoft Windows [Version 10.0.14393]
test_1  | (c) 2016 Microsoft Corporation. All rights reserved.
test_1  | 
test_1  | C:\>composeissue5371_test_1 exited with code 0

$ cat docker-compose.yml 
version: "3.2"

services:
  test:
    image: microsoft/windowsservercore
    volumes:
      - type: bind
        source: C:\Users\stefan\.ssh
        target: C:\ssh

networks:
  default:
    external:
      name: nat

Will add some comments in #5371

@StefanScherer
Copy link
Member

So it already works without setting an environment variable with 1.18.0, but with the extended syntax and natural looking single backslashes. 🎉
Is there a way to make the short syntax work as well?

@sgammill
Copy link

@StefanScherer

I think this should be solved without additional environment variables that the user has to define and know of. Instead docker-compose should recognise the Docker server platform.

I often use docker-compose config to combine .yml files, and that does not involve connecting to a Docker server. Yes, Compose could (should?) auto-detect the server platform without a client-side flag, but for config, I think some client-side mechanism would be needed.

@shin-
Copy link
Author

shin- commented Jan 11, 2018

Short syntax should work with the flag and single slashes.

@shin- shin- merged commit 9804434 into master Jan 17, 2018
@shin- shin- deleted the 5371-force-windows-volume-parsing branch February 2, 2018 19:08
@jimgolfgti
Copy link

@shin- It looks like this PR may have broken some mounts when used under Docker for Windows. Have a look at docker/for-win#1829 for details.

@shin-
Copy link
Author

shin- commented Mar 26, 2018

@jimgolfgti This change was made in 1.19.0, which was already included in Docker For Windows 18.02.0-ce. As a result, it's probably not the cause of the issue.

That said, I'll look through the changes we made in 1.20 and see if there's anything else that could have caused the issue.

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

Successfully merging this pull request may close these issues.

4 participants