docker / compose

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

Mounting is failing with wsl2 #7791

Closed giorgos321 closed 3 years ago

giorgos321 commented 4 years ago

Hi I am using docker-compose on Win 10 with WSL2 and ubuntu 20.04 distro I'am trying to mount the volume but it keeps failing and I don't know why,

I use docker-compose up and I get: <------------------------------LOG START------------------------------------------> Creating network "backend_default" with the default driver Creating volume "backend_mongo-data" with default driver Creating backend_mongo_1 ... error Creating backend_s3_1 ...

ERROR: for backend_mongo_1 Cannot start service mongo: error while mounting volume '/var/lib/docker/volumes/backend_mongo-data/_data': failed to mount local volume: mount /c/Users/hrthe/Desktop/aluplast-data/db:/var/lib/docker/volumes/backCreating backend_s3_1 ... done

ERROR: for mongo Cannot start service mongo: error while mounting volume '/var/lib/docker/volumes/backend_mongo-data/_data': failed to mount local volume: mount /c/Users/hrthe/Desktop/aluplast-data/db:/var/lib/docker/volumes/backend_mongo-data/_data, flags: 0x1000: no such file or directory ERROR: Encountered errors while bringing up the project. <--------------------------------LOG END------------------------------------------>

My sysinfo:

Client: Debug Mode: false

Server: Containers: 3 Running: 1 Paused: 0 Stopped: 2 Images: 20 Server Version: 19.03.12 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs 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: runc Default Runtime: runc Init Binary: docker-init containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 4.19.128-microsoft-standard Operating System: Docker Desktop OSType: linux Architecture: x86_64 CPUs: 6 Total Memory: 6.072GiB Name: docker-desktop ID: XGKG:Y6DR:KF2O:Y4BY:D2AG:LSHK:BG6J:PUXP:3VZY:EDFB:2DSL:STNT Docker Root Dir: /var/lib/docker Debug Mode: true File Descriptors: 50 Goroutines: 64 System Time: 2020-09-24T13:12:47.8022126Z EventsListeners: 3 Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false Product License: Community Engine

WARNING: bridge-nf-call-iptables is disabled WARNING: bridge-nf-call-ip6tables is disabled

And the docker-ompose.yml I try to run:

version: "3.2" services: mongo: image: mongo:3.6 volumes:

volumes: mongo-data: driver_opts: type: none device: /c/Users/user/Desktop/aluplast-data/db o: bind

I am trying to make it work for the past day

tomer-amir commented 4 years ago

I have the same issue in macOS after upgrading to docker desktop 2.4.0.0.

I have a compose file which runs MongoDB using a mounted volume and I got this error:

ERROR: for mongo Cannot start service mongo: error while mounting volume '/var/lib/docker/volumes/backend_mongo-data/_data': failed to mount local volume: mount /.../mount/location/:/var/lib/docker/volumes/backend_mongo-data/_data, flags: 0x1000: no such file or directory
ERROR: Encountered errors while bringing up the project.

Downgraded to 2.2.0.5 and the issue is gone

chalmagr commented 3 years ago

Facing the same issue on 2.5.0.1 (MacOS - Catalina) image

Creating network "mac-issue_default" with the default driver
Creating volume "mac-issue_data" with default driver
Creating mac-issue_service_1 ... error

ERROR: for mac-issue_service_1  Cannot start service service: error while mounting volume '/var/lib/docker/volumes/mac-issue_data/_data': failed to mount local volume: mount /opt/data:/var/lib/docker/volumes/mac-issue_data/_data, flags: 0x1000: no such file or directory

ERROR: for service  Cannot start service service: error while mounting volume '/var/lib/docker/volumes/mac-issue_data/_data': failed to mount local volume: mount /opt/data:/var/lib/docker/volumes/mac-issue_data/_data, flags: 0x1000: no such file or directory
ERROR: Encountered errors while bringing up the project.

The issue in my case is happening with a minimal docker-compose.yml is defined as below:

version: "3.8"
services:
  service:
    image: centos:7
    volumes:
      - data:/opt/data
    command:
      - /bin/bash
      - -c
      - sleep 5

volumes:
  data:
    driver_opts:
      type: none
      device: /opt/data
      o: bind

But running the same using regular docker run works fine docker run --rm -it -v /opt/data:/opt/data centos:7 /bin/bash -c "sleep 5"

mikazp commented 3 years ago

As temporary solution do not declare named volumes, this works for me:

version: '3.8'

services:
  test:
    build: .
    volumes:
      - ./:/app
    working_dir: /app

instead of

...
volumes:
  source:
    driver_opts:
      type: none
      device: .
      o: bind
stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been automatically closed because it had not recent activity during the stale period.

daniel-cohen commented 3 years ago

Still seeing the same problem on WSL: OS Version: 10.0.19043 N/A Build 19043 Docker version 20.10.8, build 3967b7d

Dhyanesh97 commented 2 years ago

Encountered same issue with below file.

version: "3"
services:
  name:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: name
    restart: always
    volumes:
      - db.sqlite3:/api/db
    ports:
      - 8000:8000
    env_file:
      - secrets.env
volumes:
  db.sqlite3:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /home/ubuntu/xxxxxx/xxxxx/db
huy8895 commented 2 years ago

i finally find the answer here : https://stackoverflow.com/questions/70326574/named-volume-with-local-bind-defined-in-docker-compose-not-working-but-working-wx#new-answer

Atralbus commented 10 months ago

As temporary solution do not declare named volumes, this works for me:

version: '3.8'

services:
  test:
    build: .
    volumes:
      - ./:/app
    working_dir: /app

instead of

...
volumes:
  source:
    driver_opts:
      type: none
      device: .
      o: bind

I spent couple of days and this was the solution to my problem. I was sure that directories exist but I was keep getting no such file or directory error no matter what I tried. Using device values in driver_opts as a prefix to volumes in services fixed it.