docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.85k stars 285 forks source link

Mounting linux path as volume work only first run #12406

Open NikitaMelikhov opened 2 years ago

NikitaMelikhov commented 2 years ago

Information

Steps to reproduce the behavior

I have such docker-compose.yml

version: '3'

services:

  traefik:
    platform: linux/amd64
    build:
      context: .
      dockerfile: ./environment/${ENVIRONMENT_NAME}/Dockerfile
    image: ${SERVICE_NAME}:${ENVIRONMENT_NAME}
    container_name: traefik
    env_file:
      - .env
    ports:
      - 80:80/tcp
      - 443:443/tcp
    networks:
      - private
      - public
    volumes:
      - traefik-certs:/etc/certs:ro

volumes:

  traefik-certs:
    name: traefik-certs
    driver: local
    driver_opts:
      type: none
      device: ${PWD}/environment/${ENVIRONMENT_NAME}/certs
      o: bind

And first time it execute fine but if i restart Windows and try run this container again i getting error: Error invoking remote method 'docker-start-container': Error: (HTTP code 500) server error - error while mounting volume '/var/lib/docker/volumes/traefik-certs/_data': failed to mount local volume: mount /run/desktop/mnt/host/wsl/docker-desktop-bind-mounts/Ubuntu-20.04/1a8c01243b0f51b6ce3beec294968223f7e139c951cc48880b4f36f9a5e28e01:/var/lib/docker/volumes/traefik-certs/_data, flags: 0x1000: no such file or directory

Why it fails? And why it works the first time?

thaJeztah commented 2 years ago

Wondering if /run/desktop/mnt/host/wsl/docker-desktop-bind-mounts/Ubuntu-20.04/1a8c01243b0f51b6ce3beec294968223f7e139c951cc48880b4f36f9a5e28e01 is some ephemeral / unique location that's generated for a new WSL2 session 🤔 (so when you restart, it creates a new ID, and the old path no longer exists)

I'm not too familiar with WSL2, but am asking around a bit if someone knows.

NikitaMelikhov commented 2 years ago

Wondering if /run/desktop/mnt/host/wsl/docker-desktop-bind-mounts/Ubuntu-20.04/1a8c01243b0f51b6ce3beec294968223f7e139c951cc48880b4f36f9a5e28e01 is some ephemeral / unique location that's generated for a new WSL2 session 🤔 (so when you restart, it creates a new ID, and the old path no longer exists)

Not sure how can i check that and what's even worse how can i fix it

NikitaMelikhov commented 2 years ago

Does anyone have any ideas?

jwhayman commented 2 years ago

+1

enyugong commented 2 years ago

+2

sixgunnar commented 2 years ago

+3 Same problem here.

TanZng commented 2 years ago

+4

bnlhv commented 2 years ago

+5

docker-robott commented 1 year ago

There hasn't been any activity on this issue for a long time. If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment. If not, this issue will be closed in 30 days.

Prevent issues from auto-closing with a /lifecycle frozen comment.

/lifecycle stale

tonybart1337 commented 1 year ago

/remove-lifecycle stale

lislon commented 1 year ago

I encountered same issue today on Win 10 and WSL2, and it was resolved when I updated Docker Desktop to 4.16.3 (96739).

During update, the VM was restarted by docker, and I suspect that this might helped to fix issue. Just for reference, here are some output that I run after updating docker:

 >  C:\Windows\system32  >  wsl -l -v
  NAME                   STATE           VERSION
* docker-desktop-data    Running         2
  docker-desktop         Running         2
  Ubuntu-20.04           Running         2

And notably, inside WSL I do not see /run/desktop/mnt/... directory:

$ ls -la /run
total 8
drwxr-xr-x  7 root root    200 Feb 17 22:15 .
drwxr-xr-x 19 root root   4096 Feb 16 17:42 ..
drwxr-xr-x  2 root root    120 Feb 17 22:15 WSL
srw-rw----  1 root docker    0 Feb 17 22:15 docker-cli.sock
-rw-r--r--  1 root root      4 Feb 17 22:15 docker-desktop-proxy.pid
srw-rw----  1 root docker    0 Feb 17 22:15 docker.sock
drwxrwxrwt  2 root root     40 Feb 16 17:42 lock
drwxr-xr-x  2 root root     40 Feb 16 17:42 mount
drwxrwxrwt  2 root root     40 Feb 16 17:42 shm
drwxr-xr-x  2 root root     40 Feb 16 17:42 user

Maybe it will help to pinpoint issue

jscontrino commented 1 year ago

+6 problem still present on latest docker desktop version (4.17.0). Only happens to me when restarting wsl (wsl.exe --shutdown) and then starting containers using existing bind volumes

docker-robot[bot] commented 1 year ago

There hasn't been any activity on this issue for a long time. If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment. If not, this issue will be closed in 30 days.

Prevent issues from auto-closing with a /lifecycle frozen comment.

/lifecycle stale

chouwwa commented 1 year ago

/remove-lifecycle stale

chouwwa commented 1 year ago

I am still facing this issue on Version 4.22.0

jblotus commented 1 year ago

Hi there - has anyone found a reliable way to re-use named volume bind mounts after a wsl shutdown? My solution so far has been to rename my volumes or project in the docker-compose.yml. The other way is to basically purge all docer desktop data but that is really undesirable. I have had mixed success with shutting down, disabling WLS2 distro integration, restarting pc, enabling wsl integration, restarting but nothing conclusive.

garytimuss commented 9 months ago

I had been seeing something very similar in a volume mount (but still had a "bind mount" error message), flags: 0x5001 that was mysteriously 'resolved' by removing the :ro flag

mcabej commented 7 months ago

+7 Still happening as of 26/01/2024.

The following error happens when I reboot WSL/Windows:

Error response from daemon: error while mounting volume '/var/lib/docker/volumes/app/_data': failed to mount local volume: mount /run/desktop/mnt/host/wsl/docker-desktop-bind-mounts/Ubuntu/65a970e7b427d3f6de9844447cb7e0ecf4c6b58160be9705401f0b2e4e479bd7:/var/lib/docker/volumes/app/_data, flags: 0x1000: no such file or directory

Workaround I'm currently using is removing Docker Desktop and installing Docker straight into WSL.

zerox7felf commented 5 months ago

Still seeing this exact issue in v4.28.0 on Windows 11. I start a container with a mounted file, then update the file, restart the container, and get the same error as above. "Workaround" is to restart the docker engine, after which it works again. (Until I update the file of course....)