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

Missing secrets file creates a directory? #5377

Closed
aaparmeggiani opened this issue Nov 15, 2017 · 5 comments
Closed

Missing secrets file creates a directory? #5377

aaparmeggiani opened this issue Nov 15, 2017 · 5 comments

Comments

@aaparmeggiani
Copy link

When docker-compose up with the config below, if the file mypass.txt is missing, docker-compose creates an empty directory mypass.txt. Is that expected behaviour?

version: '3.1'

services:
  app:
    image: alpine
    secrets:
      - mypass

secrets:
  mypass:
    file: ./mypass.txt

macOS 10.13.1
Docker version 17.11.0-ce-rc3, build 5b4af4f
docker-compose version 1.17.0, build ac53b73

@shin-
Copy link

shin- commented Nov 15, 2017

It's a somewhat unfortunate side-effect of the way we emulate secrets in docker-compose. Incidentally, it will be fixed by #5363, which will error out instead if the specified file is missing.

@RJPercival
Copy link

RJPercival commented Nov 23, 2018

#5363 was never merged, which means this may never have been fixed. Consider re-opening?

@shin-
Copy link

shin- commented Nov 23, 2018

It was fixed by #5415

@snpz
Copy link

snpz commented Apr 24, 2021

Hi @shin-

I just encountered this issue with docker-compose in WSL.
The secret file does not exist after cloning my repo and compose seems to call mkdir in that moment.
It fails to do so because there is already a file with that id. In my project in the secrets folder also a new directory called like the secret appears.

docker-compose --profile backend up --no-build --detach
WARNING: Service "service-db" uses an undefined secret file "/home/snpz/Portal/secrets/service-db-pass", the following file should be created "/home/snpz/Portal/secrets/service-db-pass"
Creating network "portal_default" with the default driver
Creating service-db ... error

ERROR: for service-db  Cannot create container for service service-db: mkdir /wsl/docker-desktop-bind-mounts/Debian/90cbcba226ca7bbb747654e7273e6f652a56efccc03d744699fc453acdcb3d8b: mkdir /wsl/docker-desktop-bind-mounts/Debian/90cbcba226ca7bbb747654e7273e6f652a56efccc03d744699fc453acdcb3d8b: not a directory

ERROR: for service-db  Cannot create container for service service-db: mkdir /wsl/docker-desktop-bind-mounts/Debian/90cbcba226ca7bbb747654e7273e6f652a56efccc03d744699fc453acdcb3d8b: mkdir /wsl/docker-desktop-bind-mounts/Debian/90cbcba226ca7bbb747654e7273e6f652a56efccc03d744699fc453acdcb3d8b: not a directory
ERROR: Encountered errors while bringing up the project.
make: *** [Makefile:38: backend-up] Error 1

Output of docker-compose version

docker-compose version 1.29.0, build 07737305
docker-py version: 5.0.0
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

If you need more input please just let me know.

Maybe this is just how bind mounts work. It took me a while to figure out that I had to delete the created folder in /wsl/docker-desktop-bind-mounts too before I could add my missing secret file to make it work again.

Update:
Possibly it could fail here instead of warning to avoid this?

@philliphoff
Copy link

I'm also seeing this behavior (a missing secrets file results in a directory created when the composition is started) with Docker Desktop for Windows (v3.3.1 b63152, with WSL2 engine enabled) but, interestingly, not with Docker Desktop for Mac (v3.3.1 b63152).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants