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

--context may require setting COMPOSE_CONVERT_WINDOWS_PATHS #7524

Closed
davetapley opened this issue Jun 8, 2020 · 2 comments
Closed

--context may require setting COMPOSE_CONVERT_WINDOWS_PATHS #7524

davetapley opened this issue Jun 8, 2020 · 2 comments
Labels

Comments

@davetapley
Copy link

Description of the issue

Using the --context support added in 1.26.0,
with docker-compose installed on Windows,
and a remote host context running Ubuntu,
when starting a service having a volume specified in docker-compose.yml,
then you get Cannot create container for service [...]: invalid volume specification,
unless you also set $env:COMPOSE_CONVERT_WINDOWS_PATHS = 1.

Context information (for bug reports)

Output of docker-compose version

> docker-compose.exe version
docker-compose version 1.26.0, build d4451659
docker-py version: 4.2.1
CPython version: 3.7.4
OpenSSL version: OpenSSL 1.1.1c  28 May 2019

Output of docker version

Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:23:10 2020
 OS/Arch:           windows/amd64
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker-compose config
(Make sure to add the relevant -f and other flags)

services:
  core:
    command: REDACTED
    image: REDACTED
    volumes:
    - /c/Users/dave/Documents/GitHub/REDACTED/Core:/REDACTED/Core:rw
    working_dir: /REDACTED/Core
version: '3.7'

Steps to reproduce the issue

  1. Be running docker-compose 1.26.0 on Windows 10

  2. Be running Docker on Ubuntu 18.04.4 LTS

  3. Add a docker context pointing to the Linux instance, such that docker context ls gives e.g:

    NAME                DESCRIPTION                               DOCKER ENDPOINT                  KUBERNETES ENDPOINT   ORCHESTRATOR
    default *           Current DOCKER_HOST based configuration   npipe:////./pipe/docker_engine                  swarm
    ubuntu                                                        ssh://dave@ubuntu
    
  4. Run docker-compose --context ubuntu up core

Observed result

ERROR: for d5f9d1c87360_redacted_core_1  Cannot create container for service core: invalid volume specification: 'C:\Users\dave\Documents\GitHub\REDACTED\Core:/REDACTED/Core:rw'

Expected result

The core service starting up as it would have running docker-compose up core (i.e. without --context ubuntu)

Stacktrace / full error message

ERROR: for d5f9d1c87360_redacted_core_1  Cannot create container for service core: invalid volume specification: 'C:\Users\dave\Documents\GitHub\REDACTED\Core:/REDACTED/Core:rw'

Additional information

docker-compose 1.26.0 on Windows 10

Docker on Ubuntu 18.04.4 LTS

I manually got docker-compose-Windows-x86_64.exe from https://github.com/docker/compose/releases/tag/1.26.0, since it hasn't been bundled in to Docker Desktop for Windows yet.

I can work around this issue by setting $env:COMPOSE_CONVERT_WINDOWS_PATHS = 1 prior to running docker-compose --context ubuntu up core.

@davetapley
Copy link
Author

davetapley commented Jun 9, 2020

I realized I am even more confused by this because, as I now understand it:
Volume mounts are relative to the host running Docker, not on the file system where docker-compose is being run.

It sounds like this confusion is kind of similar to #6697.

@davetapley
Copy link
Author

I'm going to close this based on ⬆️ and my community post it prompted, specifically:

As I now understand it: compose doesn't support volumes where the source is on the machine which is running compose, as opposed to the machine which is running the Docker engine itself.

This bug (#7524) exists only because I failed to understand that, and thus when I thought I was specifying a volume source on my Windows machine (running compose), I was actually specifying a volume source on my Ubuntu machine, hence invalid volume specification.


Cautionary tale: I do suspect that when the --context option is more generally available it might prompt people to try it, and then run in to more confusion discovering that the volumes are on the host, and not on the machine running compose.

I think that is evidenced by the long running existence of #2957.

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

No branches or pull requests

1 participant