Open philliphoff opened 3 years ago
I'm not 100% sure, but I think this issue has gotten worse recently on Docker Deskop for Windows.
If the file: ./mypass.txt
is missing, it creates a directory in the current directory called mypass.txt
. It has been like that "for a long time".
(I'm pretty sure) it used to be that I could then:
docker-compose down
rmdir mypass.txt
echo contents > mypass.txt
docker-compose up -d
and that would be the end of it.
But now when I do that last step, I get:
WSL2@~/idea/app» docker-compose up -d
Creating network "app_default" with the default driver
Creating app_app_1 ... error
ERROR: for app_app_1 Cannot create container for service app: not a directory
ERROR: for app Cannot create container for service app: not a directory
ERROR: Encountered errors while bringing up the project.
To get rid of that error, I now have to:
WSL2@~/idea/app» sudo rm -r /mnt/wsl/docker-desktop-bind-mounts/Ubuntu-20.04-v2/e47c2d04a4b94e64079cbd50e60e132e8e5670dbd7d9fc84721344f3f2b4e105
and then it works:
WSL2@~/idea/app» docker-compose up -d
Creating network "app_default" with the default driver
Creating app_app_1 ... done
I have no idea how to identify the correct e47c2d04a4b94e64079cbd50e60e132e8e5670dbd7d9fc84721344f3f2b4e105
file under /mnt/wsl/docker-desktop-bind-mounts/Ubuntu-20.04-v2
but the timestamp may help and I found that quitting Docker Desktop for Windows and then:
WSL2@~/idea/app» sudo rm -r /mnt/wsl/docker-desktop-bind-mounts/Ubuntu-20.04-v2/*
And then restarting Docker Desktop works too.
Note: I was worried that this sudo rm -r .../*
might loose data somehow, but I didn't have any data I didn't mind loosing. You might. Be careful and investigate what you're deleting... Even though I didn't mind loosing them, I checked and all my volume contents were still intact afterwards
WSL2@~/idea/app» docker-compose version
docker-compose version 1.29.1, build c34c88b2
docker-py version: 5.0.0
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
For anyone reading the comment above - be VERY careful following the advice to delete some directories under /mnt/wsl/docker-desktop-bind-mounts/
It has the potential to not only delete Docker volumes, but delete your entire WSL filesystem. I just found out the hard way.
I'm not sure if this is to do with a recent update to Docker Desktop and some sort of symlinking, but I really hope this secrets mounting issue can be fixed at some point.
It's not just about missing secrets file. My secrets files are there but I get the error.
I'm in a WSL 2 VS Code dev container.
Interestingly, this happens to me on my brand new debian baremetal docker install.
On my old debian server which has docker at the exact same version of every component, but was upgraded starting from an early 2020 docker version does not have this issue. The difference was the parent folder permissions.
The difference between them for me was that the secrets directory (not the files themselves) needs group execute permissions. I don't know how applicable it is for windows, but it seems to be a permissions issue?
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.
Still a problem, current behavior:
version: '3.8'
secrets:
my_secret:
file: my_secret.txt
services:
hello-world:
image: hello-world
secrets:
- my_secret
> docker-compose up
WARNING: Service "hello-world" uses an undefined secret file "C:\Users\micah\Source\temp\my_secret.txt", the following file should be created "C:\Users\micah\Source\temp\my_secret.txt"
...
my_secret.txt
directory is createdIf you delete the folder and run docker-compose up
again, you now get a failure:
> docker-compose up
WARNING: Service "hello-world" uses an undefined secret file "C:\...\my_secret.txt", the following file should be created "C:\...\my_secret.txt"
Starting temp_hello-world_1 ... error
ERROR: for temp_hello-world_1 Cannot start service hello-world: invalid mount config for type "bind": bind source path does not exist: /run/desktop/mnt/host/c/.../my_secret.txt
Deleting the folder and then creating a text file in its place results in the following failure:
> docker-compose up
Starting temp_hello-world_1 ... error
ERROR: for temp_hello-world_1 Cannot start service hello-world: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/run/desktop/mnt/host/c/.../my_secret.txt" to rootfs at "/run/secrets/my_secret" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
@stale Not stale.
The above replicated on: Docker Desktop: 4.4.4 (73704 Docker Engine: 20.10.12 Docker Compose: 1.29.2
FYI Docker Compose V1, the python version, reached end-of-life, please use Compose v2 instead and let us know if you still have the problem with this version. You can simply switch to Compose V2 by checking the checkbox in Docker Desktop preferences
Tested with Docker Compose v2 per above instructions: New behavior (still broken):
docker-compose up
again I get the following error:
> docker-compose up
[+] Running 1/0
- Container temp-hello-world-1 Created
Attaching to temp-hello-world-1
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /run/desktop/mnt/host/c/.../my_secret.txt
docker-compose up
attempt results in this error:
> docker-compose up
[+] Running 1/0
- Container temp-hello-world-1 Created
Attaching to temp-hello-world-1
Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/run/desktop/mnt/host/c/.../my_secret.txt" to rootfs at "/run/secrets/my_secret" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
This issue has been automatically marked as not stale anymore due to the recent activity.
This issue has been automatically marked as not stale anymore due to the recent activity.
Any progress? I have same issue as @MicahZoltu
I also have this issue and get the same result now with v3
It appears to be fixed
It looks not :-) (Latest Docker Desktop 4.30.0, latest updated Windows)
Error response from daemon: failed to create task for container: failed to create shim task:
OCI runtime create failed: runc create failed: unable to start container process: error during container init:
error mounting "/run/desktop/mnt/host/c/_/Dev/XXX/docker/secrets/postgres_password.txt" to rootfs at "/run/secrets/postgres_password":
mount /run/desktop/mnt/host/c/_/Dev/XXX/docker/secrets/postgres_password.txt:/run/secrets/postgres_password (via /proc/self/fd/6),
flags: 0x5000: not a directory: unknown:
Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
file `c:\_\Dev\XXX\docker\secrets\postgres_password.txt` exists.
docker-compose.yml:
services: database: ... secrets:
Any solution to get secrets working?
**UPDATE/FIX:** i comment secrets definition, recreate container (this probably delete old mounts), un-comment secrets, recreate container again (now are mounts correctly mapped) and it start without error
The only way i have gotten it to work sofar is by running docker-compose up --build
by going into the WSL terminal first.
Description of the issue
On Windows, when starting a composition that refers to a secret file which does not exist, an "invalid mount config for type" error is generated and a directory with the same name as the file is created.
This behavior is not seen on Mac, with the same version of Docker Desktop and Docker Compose.
This may be related to #5377 but seems only to affect Windows.
Context information (for bug reports)
Output of
docker-compose version
Output of
docker version
Output of
docker-compose config
(Make sure to add the relevant-f
and other flags)Steps to reproduce the issue
docker-compose.yml
in an otherwise empty directory:docker-compose up --remove-orphans
Observed result
Expected result
Stacktrace / full error message
Additional information
OS version / distribution,
docker-compose
install method, etc.Windows 10 (Version 21H1, OS Build 19043.964)