Skip to content

Docker-compose rejects windows style volume mappings #3897

Closed

Description

@NCarlsonMSFT

When building windows containers a compose file like:

foo:
    image: windowsservercore
    volumes:
        - C:\foo:C:\bar:ro

Results in the error:
ERROR: Volume c:\foo:c:\bar:ro has incorrect format, should be external:internal[:mode]

But if I call docker directly with "docker run -v C:\foo:C:\bar:ro windowsservercore" it is accepted as expected.

Activity

  1. friism commented on Aug 31, 2016

    @friism
  2. NCarlsonMSFT commented on Aug 31, 2016

    @NCarlsonMSFT
    Author

    FYI if I use "/C/Foo:/C/Bar:ro" instead the error is:

    ERROR: for foo Invalid volume spec "/C/Bar": Invalid volume specification: '/C/Bar'
    Traceback (most recent call last):
    File "", line 3, in
    File "compose\cli\main.py", line 63, in main
    AttributeError: 'ProjectError' object has no attribute 'msg'
    docker-compose returned -1

  3. shin- commented on Aug 31, 2016

    @shin-

    @NCarlsonMSFT I think you're using an older version of compose, can you try upgrading to 1.8.0?

  4. shin- commented on Aug 31, 2016

    @shin-

    It's a duplicate of #2487, which we fixed in 1.8.

  5. NCarlsonMSFT commented on Aug 31, 2016

    @NCarlsonMSFT
    Author

    I was on an older build, I switched to "docker-compose version 1.8.0, build d988a55" and am still getting the errors

  6. shin- commented on Aug 31, 2016

    @shin-

    Can you share the full output of docker-compose --verbose config?

  7. NCarlsonMSFT commented on Aug 31, 2016

    @NCarlsonMSFT
    Author
    PS > docker-compose --verbose config
    compose.config.config.find: Using configuration files: .\docker-compose.yml
    ERROR: compose.cli.main.main: Volume C:\Foo:C:\Bar:ro has incorrect format, should be external:internal[:mode]
    
  8. NCarlsonMSFT commented on Aug 31, 2016

    @NCarlsonMSFT
    Author

    Interestingly if I run docker-compose --verbose config on the v2 equivalent of the file that succeeds:

    compose.config.config.find: Using configuration files: .\docker-compose.yml
    networks: {}
    services:
      foo:
        image: windowsservercore
        volumes:
        - /c/Foo:C:\Bar
    version: '2.0'
    volumes: {}
    
  9. PatrickLang commented on Sep 2, 2016

    @PatrickLang

    here's another variation:

    I created a directory and file on the host:

    PS C:\compose1> ls ~/shared
    
    
        Directory: C:\Users\vagrant\shared
    
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    -a----         9/1/2016   5:37 PM             16 hello.txt
    

    And here's the docker-compose.yml:

    PS C:\compose1> cat .\docker-compose.yml
    version: '2'
    services:
      shell:
        image: microsoft/windowsservercore
        tty: true
        network_mode: "none"
        volumes:
          - ~/shared:/c/shared
    

    It parsed ok:

    PS C:\compose1> docker-compose --verbose config
    compose.config.config.find: Using configuration files: .\docker-compose.yml
    networks: {}
    services:
      shell:
        image: microsoft/windowsservercore
        network_mode: none
        tty: true
        volumes:
        - /c/Users/vagrant/shared:/c/shared:rw
    version: '2.0'
    volumes: {}
    

    But failed to run:

    PS C:\compose1> docker-compose up -d
    Creating compose1_shell_1
    
    ERROR: for shell  Cannot create container for service shell: Invalid volume spec "/c/shared": Invalid volume specification: '/c/shared'
    ERROR: Encountered errors while bringing up the project.
    

    I am also running docker-compose version 1.8.0, build d988a55

  10. shin- commented on Sep 8, 2016

    @shin-

    Thank you for providing more details. I think I identified what the problem is and will be working on a fix.

  11. added this to the 1.8.1 milestone on Sep 8, 2016
  12. 2 remaining items

  13. StefanScherer commented on Oct 11, 2016

    @StefanScherer
    Member

    Quick test:

    C:\Users\vagrant\test> mkdir c:\shared
    C:\Users\vagrant\test> cat .\docker-compose.yml
    version: '2'
    services:
      shell:
        image: microsoft/windowsservercore
        tty: true
        network_mode: "none"
        volumes:
          - c:\shared:c:\shared
    

    Test with docker-dompose 1.8.1:

    C:\Users\vagrant\test> docker-compose up -d
    Creating test_shell_1
    
    ERROR: for shell  Cannot create container for service shell: invalid volume spec "/c/shared": invalid volume specification: '\c\shared'
    �[31mERROR�[0m: Encountered errors while bringing up the project.
    

    Downloading artifact and testing again:

    C:\Users\vagrant\test> wget -outfile docker-compose.exe https://ci.appveyor.com/api/buildjobs/mjk334rrdx7p591d/artifacts/dist%2Fdocker-compose-Window
    s-x86_64.exe
    C:\Users\vagrant\test> .\docker-compose.exe up -d
    �[33mWARNING�[0m: The COMPOSE_CONVERT_WIN32_PATHS variable is not set. Defaulting to a blank string.
    Traceback (most recent call last):
      File "<string>", line 3, in <module>
      File "compose\cli\main.py", line 62, in main
      File "compose\cli\main.py", line 114, in perform_command
      File "compose\cli\main.py", line 835, in up
      File "compose\project.py", line 372, in up
      File "compose\project.py", line 539, in warn_for_swarm_mode
      File "site-packages\docker\api\daemon.py", line 33, in info
      File "site-packages\docker\utils\decorators.py", line 47, in inner
      File "site-packages\docker\client.py", line 139, in _get
      File "site-packages\requests\sessions.py", line 477, in get
      File "site-packages\requests\sessions.py", line 465, in request
      File "site-packages\requests\sessions.py", line 573, in send
      File "site-packages\requests\adapters.py", line 370, in send
      File "site-packages\requests\packages\urllib3\connectionpool.py", line 544, in urlopen
      File "site-packages\requests\packages\urllib3\connectionpool.py", line 374, in _make_request
      File "httplib.py", line 1133, in getresponse
      File "httplib.py", line 390, in __init__
      File "site-packages\docker\transport\npipesocket.py", line 99, in makefile
    ValueError: buffer size must be strictly positive
    docker-compose returned -1
    
  14. shin- commented on Oct 11, 2016

    @shin-

    @StefanScherer Thank you for testing. What does it say when you run .\docker-compose.exe version?

  15. StefanScherer commented on Oct 11, 2016

    @StefanScherer
    Member

    @shin-

    C:\Users\vagrant\test> .\docker-compose.exe --version
    docker-compose version 1.9.0dev, build 31904b7
    
  16. StefanScherer commented on Oct 11, 2016

    @StefanScherer
    Member

    And now without double dashes:

    C:\Users\vagrant\test> .\docker-compose.exe version
    docker-compose version 1.9.0dev, build 31904b7
    docker-py version: 1.10.3
    CPython version: 2.7.12
    OpenSSL version: OpenSSL 1.0.2h  3 May 2016
    
  17. shin- commented on Oct 11, 2016

    @shin-

    @StefanScherer Thanks - looks like we still have some challenges with named pipe support. In the meantime you can work around this by connecting via TCP using the DOCKER_HOST environment variable.

  18. StefanScherer commented on Oct 11, 2016

    @StefanScherer
    Member

    @shin- Thanks! Yes, setting DOCKER_HOST to TCP works.

    But colored output in PowerShell also needs some care:

    bildschirmfoto 2016-10-12 um 00 19 17

  19. shin- commented on Oct 11, 2016

    @shin-

    @StefanScherer Thank you!

    And agreed re: coloring. I think we have an issue open for that.

  20. realtebo commented on Jan 24, 2017

    @realtebo

    Same issue on windows 7.

    My intent is to copy the content of dir C:\Users\realtebo\Downloads\new\actual-wordpress\www into /var/www/html

    My docker-compose.yaml is inside C:\Users\realtebo\Downloads\new. Here is the relevant section

     wordpress:
        container_name: wordpress
        image: php:5.5-apache
        volumes:
          - ./actual-wordpress/www/:/var/www/html
    

    About docker-compose itselfs:

    $ docker-compose --version
    docker-compose version 1.9.0, build 2585387
    
    $ echo $DOCKER_HOST
    tcp://192.168.99.100:2376
    
    

    The error:

    Building db
    Step 1 : FROM mysql:5.5
     ---> 98ae577069d3
    Step 2 : COPY www.sql /docker-entrypoint-initdb.d
     ---> Using cache
     ---> 0111b4d94141
    Successfully built 0111b4d94141
    Recreating db
    Recreating 5b0969d43690_wordpress
    
    ERROR: for wordpress  Cannot create container for service wordpress: Invalid bin
    d mount spec "C:\\Users\\realtebo\\Downloads\\new\\actual-wordpress\\www:/va
    r/www/html:rw": Invalid volume specification: 'C:\Users\realtebo\Downloads\n
    ew\actual-wordpress\www:/var/www/html:rw'
    ←[31mERROR←[0m: Encountered errors while bringing up the project.
    

    I'm on Windows 7, so no PowerShell. My cli is inside MINGW64.

    what can I do?

  21. shin- commented on Jan 24, 2017

    @shin-

    @realtebo Please update to docker-compose 1.10

  22. realtebo commented on Jan 25, 2017

    @realtebo
  23. realtebo commented on Jan 25, 2017

    @realtebo

    For love of documenting and debugging, I tried to change declaration in the yaml file as is:

    volumes:
      - /c/Users/realtebo/Downloads/new/actual-wordpress/www:/var/www/html
    

    And error is changed:

    ERROR: for wordpress Cannot create container for service wordpress: create \c\U
    sers\realtebo\Downloads\new\actual-wordpress\www: "\c\Users\realtebo
    \Downloads\new\actual-wordpress\www" 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.

    $ docker --version
    Docker version 1.12.6, build 78d1802
    $ docker-compose --version
    docker-compose version 1.10.0, build 4bd6f1a0
    
  24. realtebo commented on Jan 30, 2017

    @realtebo

    @shin: any news on a new patch for windows users?

  25. shin- commented on Jan 30, 2017

    @shin-

    @realtebo You say you're on Win7, I assume that means you're working with Docker Machine? If so, did you enable the COMPOSE_CONVERT_WINDOWS_PATHS environment variable? See docs here

  26. realtebo commented on Jan 31, 2017

    @realtebo

    @shin- : I created a .env file inside the same folder of docker-compose.yml.

    This is the actual content of the file

    $ cat .env
    COMPOSE_CONVERT_WINDOWS_PATHS=1
    

    Now it's working. Thanks.
    Please, add it to the doc in the section about VOLUME of docker compose

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions