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

Docker Compose V2 with Docker Desktop on Windows / WSL2 gives "/mnt/c not a shared mount" error #8558

Closed
arachnetech opened this issue Aug 1, 2021 · 4 comments · Fixed by compose-spec/compose-go#206
Labels

Comments

@arachnetech
Copy link

Description

Docker Desktop updated and enabled the 'Use Docker Compose V2' experimental feature.

My previously-working docker-compose configuration, run from WSL2, sharing files in the Windows filesystem, gives errors like:

Error response from daemon: path /mnt/c/path/to/dir is mounted on /mnt/c but it is not a shared mount.

Disabling the experimental feature: Use Docker Compose V2, it works fine.

Steps to reproduce the issue:

  1. Use the following docker-compose.yml file
version: "3.7"

services:
  redis:
    image: redis:6-alpine
    volumes: 
      - './data/:/data/'
    ports:
      - 6379:6379
  1. With Use Docker Compose V2 enabled, run docker-compose up

Describe the results you received:

WSL2 davidm@David-WinDev:/mnt/c/Work/dockertest$ docker-compose up
[+] Running 0/0
 ⠋ Container dockertest_redis_1  Creating                                                                     0.0s
Error response from daemon: path /mnt/c/Work/dockertest/data is mounted on /mnt/c but it is not a shared mount. 

As expected, docker compose up does the same without Use Docker Compose V2 enabled:

WSL2 davidm@David-WinDev:/mnt/c/Work/dockertest$ docker compose up
[+] Running 0/1
 ⠙ Container dockertest_redis_1  Recreate                                                                                                                                           0.1s
Error response from daemon: path /mnt/c/Work/dockertest/data is mounted on /mnt/c but it is not a shared mount.

Describe the results you expected:

Without Use Docker Compose V2, it runs as expected:

WSL2 davidm@David-WinDev:/mnt/c/Work/dockertest$ docker-compose up
Creating dockertest_redis_1 ... done
Attaching to dockertest_redis_1
redis_1  | 1:C 01 Aug 2021 17:49:37.141 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1  | 1:C 01 Aug 2021 17:49:37.141 # Redis version=6.2.3, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1  | 1:C 01 Aug 2021 17:49:37.141 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1  | 1:M 01 Aug 2021 17:49:37.141 * monotonic clock: POSIX clock_gettime
redis_1  | 1:M 01 Aug 2021 17:49:37.142 * Running mode=standalone, port=6379.
redis_1  | 1:M 01 Aug 2021 17:49:37.142 # Server initialized
redis_1  | 1:M 01 Aug 2021 17:49:37.142 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1  | 1:M 01 Aug 2021 17:49:37.143 * Loading RDB produced by version 6.2.3
redis_1  | 1:M 01 Aug 2021 17:49:37.143 * RDB age 175 seconds
redis_1  | 1:M 01 Aug 2021 17:49:37.143 * RDB memory usage when created 0.77 Mb
redis_1  | 1:M 01 Aug 2021 17:49:37.143 * DB loaded from disk: 0.001 seconds
redis_1  | 1:M 01 Aug 2021 17:49:37.143 * Ready to accept connections

Output of docker-compose --version:

docker-compose version 1.29.2, build 5becea4c

Output of docker version:

Client: Docker Engine - Community
 Cloud integration: 1.0.17
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        f0df350
 Built:             Wed Jun  2 11:56:47 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.7
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       b0f5bc3
  Built:            Wed Jun  2 11:54:58 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.6
  GitCommit:        d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc:
  Version:          1.0.0-rc95
  GitCommit:        b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker context show:

default

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  compose: Docker Compose (Docker Inc., v2.0.0-beta.6)
  scan: Docker Scan (Docker Inc., v0.8.0)
WARNING: Plugin "/usr/libexec/docker/cli-plugins/docker-app" is not valid: failed to fetch metadata: fork/exec /usr/libexec/docker/cli-plugins/docker-app: no such file or directory     

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 17
 Server Version: 20.10.7
 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: d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc version: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.16.3-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 25.01GiB
 Name: docker-desktop
 ID: DACX:L5VQ:PU2Z:YDVQ:GBR5:ZTYG:EOMT:63AZ:NQAH:3UWF:USYF:QIK7
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
@arachnetech arachnetech changed the title Docker Compose V2 on with Docker Desktop on Windows / WSL2 gives "/mnt/c not a shared mount" error Docker Compose V2 with Docker Desktop on Windows / WSL2 gives "/mnt/c not a shared mount" error Aug 1, 2021
@ndeloof ndeloof transferred this issue from docker-archive/compose-cli Sep 2, 2021
@jpetazzo
Copy link

jpetazzo commented Oct 2, 2021

This seems to happen when the volumes are specified with trailing slashes.

Specifically, this Compose file doesn't work with Compose v2:

version: "3"

services:
  redis:
    image: redis
    volumes: 
      - ./data/:/data/

But this one does:

version: "3"

services:
  redis:
    image: redis
    volumes: 
      - ./data:/data

And the latter works fine with Compose v1.

Until it gets fixed, as a workaround, you can remove the trailing slashes from your Compose file, or run the Compose file with Compose v1 (on my WSL install, I can run docker-compose-v1 up and it works in a pinch).

@jpetazzo
Copy link

jpetazzo commented Oct 2, 2021

Extra info: on Linux, there is a slightly different (perhaps related) bug.

When trying to bind-mount a local directory, if the directory doesn't exist, we get the following error message:

Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /tmp/compose-file-slash/data

This is with Docker Compose version v2.0.1, using the following Compose file:

version: "3"

services:
  redis:
    image: redis
    volumes: 
      - ./data/:/data/

Now, the funny thing is that if you run it with Compose v1, it works, and creates the directory; and after the directory is created, it will work on Compose v2. And running without the trailing slashes on Compose v2 will work even if the directory is not created (and it will create it).

@pombredanne
Copy link

I can confirm that removing trailing slash in volumes fixed the issue

@mikerosas
Copy link

Such an easy fix, ported the docker-compose yaml from my linux setup, didn't ran with the issue there.

regisb added a commit to overhangio/tutor that referenced this issue Dec 8, 2021
- 💥[Improvement] Fail on incorrect image name argument in `images
build/pull/push/printtag` commands.
- [Bugfix] Remove trailing slashes in docker-compose files for
[compatibility with docker-compose v2 in
WSL](docker/compose#8558).
- [Improvement] `settheme` now works with preview domain.
- [Feature] Allow specifying extra pip packages through config.yml.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants