docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.74k stars 5.19k forks source link

COMPOSE_CONVERT_WINDOWS_PATHS causes relative bind-mounts to fail #9428

Closed rfay closed 2 years ago

rfay commented 2 years ago

Description

I tested this with compose 2.5.0, but I imagine the problem was introduced in 2.4.0+

With COMPOSE_CONVERT_WINDOWS_PATHS=true, relative paths can't be used as bind-mounts

Steps to reproduce the issue:

Use this docker-compose.yaml

services:
  web:
    image: busybox
    command: tail -f /dev/null
    volumes:
    - ../:/var/www/html
    - ./xhprof:/usr/local/bin/xhhprof
export COMPOSE_CONVERT_WINDOWS_PATHS=false
docker-compose up -d

(works fine)

export COMPOSE_CONVERT_WINDOWS_PATHS=true
docker-compose up -d
[+] Running 0/0
 ⠋ Container 5fe7239b333d_ddev-web-1  Recreate                                                           0.0s
Error response from daemon: create ../: "../" 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

fails completely, rejecting the relative bind-mounts

Describe the results you expected:

Relative bind mounts of this type have worked for years, and work fine with COMPOSE_CONVERT_WINDOWS_PATHS=false

Output of docker compose version:

Docker Compose version v2.5.0

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.8.1-docker)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 3
  Running: 0
  Paused: 0
  Stopped: 3
 Images: 32
 Server Version: 20.10.14
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc version: v1.0.3-0-gf46b6ba
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.13.0-1022-aws
 Operating System: Ubuntu 20.04.4 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 1.928GiB
 Name: ip-172-30-100-92
 ID: ZPYR:CTRZ:2VDT:GMS3:KU4C:JRTQ:SHGU:K5IR:FGY2:3BW4:T4GD:T7PG
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: randyfay
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
kkbruce commented 2 years ago

We, from docker-compose 1.29.2 upgrade to docker-compose 2.5.0, found this error:

Error response from daemon: invalid volume specification: 'D:\\WorkflowUploadfile:C:\app\destination:rw'

older 1.x support 'D:\\' format, 2.x don't support.

dariusvelavicius commented 2 years ago

Confirming the issue on my end as well. Have to downgrade to 2.4.1 or use COMPOSE_CONVERT_WINDOWS_PATHS=false for the containers to start.

Ghoughpteighbteau commented 2 years ago

I'm seeing this behavior as well.

┬─[oehpr@oehpr-q6:~/d/l/services]─[03:13:33 PM]─[G:Automations=]
╰─>$ COMPOSE_CONVERT_WINDOWS_PATHS=true dc up -d
[+] Running 18/21
 ⠿ Container services-marathon-1           Running                                                                       0.0s
...
 ⠇ Container services-cas-1                Recreate                                                                     10.8s
Error response from daemon: create ./certs/: "./certs/" 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

┬─[oehpr@oehpr-q6:~/d/l/services]─[03:13:49 PM]─[G:Automations=]
╰─>$ COMPOSE_CONVERT_WINDOWS_PATHS=false dc up -d
[+] Running 21/21
 ⠿ Container services-works_ui-1                    Running                                                              0.0s
...
 ⠿ Container aa4f11dcffec_services-email-1          Started                                                              1.4s

┬─[oehpr@oehpr-q6:~/d/l/services]─[03:14:23 PM]─[G:Automations=]
╰─>$

Thank you @rfay for figuring out the envvar! Awesome work!

ghost commented 2 years ago

Description

I tested this with compose 2.5.0, but I imagine the problem was introduced in 2.4.0+

With COMPOSE_CONVERT_WINDOWS_PATHS=true, relative paths can't be used as bind-mounts

Steps to reproduce the issue:

Use this docker-compose.yaml

services:
  web:
    image: busybox
    command: tail -f /dev/null
    volumes:
    - ../:/var/www/html
    - ./xhprof:/usr/local/bin/xhhprof
export COMPOSE_CONVERT_WINDOWS_PATHS=false
docker-compose up -d

(works fine)

export COMPOSE_CONVERT_WINDOWS_PATHS=true
docker-compose up -d
[+] Running 0/0
 ⠋ Container 5fe7239b333d_ddev-web-1  Recreate                                                           0.0s
Error response from daemon: create ../: "../" 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

fails completely, rejecting the relative bind-mounts

Describe the results you expected:

Relative bind mounts of this type have worked for years, and work fine with COMPOSE_CONVERT_WINDOWS_PATHS=false

Output of docker compose version:

Docker Compose version v2.5.0

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.8.1-docker)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 3
  Running: 0
  Paused: 0
  Stopped: 3
 Images: 32
 Server Version: 20.10.14
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc version: v1.0.3-0-gf46b6ba
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.13.0-1022-aws
 Operating System: Ubuntu 20.04.4 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 1.928GiB
 Name: ip-172-30-100-92
 ID: ZPYR:CTRZ:2VDT:GMS3:KU4C:JRTQ:SHGU:K5IR:FGY2:3BW4:T4GD:T7PG
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: randyfay
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
datpt-nfq commented 2 years ago

Add bellow line in docker\deployment\default\deploy file

export COMPOSE_CONVERT_WINDOWS_PATHS=false

paslandau commented 2 years ago

Confirming this bug for Docker Desktop on Win as well as Mac

rfay commented 2 years ago

This seems to be fixed in compose 2.5.1, yay!