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

Letter and two digit root folder name causes docker-compose to fail creating directories inside the volume #6248

Closed
2 tasks done
Taar opened this issue Apr 6, 2020 · 4 comments

Comments

@Taar
Copy link

Taar commented Apr 6, 2020

  • I have tried with the latest version of my channel (Stable or Edge)
  • I have uploaded Diagnostics
  • Diagnostics ID: E17AEFEE-441C-4A83-91AE-8FEDB27A3E69/20200406170457

Expected behavior

docker-compose up should be able to create folders in the volumes it creates when ran in WSL2 environment regardless of what the parent folders name is.

Actual behavior

Assuming the folder has the following docker-compose.yml file:

version: "3.4"
services:

  db-test:
    image: postgres:alpine
    volumes:
      - db-data-volume:/var/lib/postgresql/data

volumes:
  db-data-volume:

docker-compose up produces the error below only on WSL2 and if the parent folder's name matches the following regex [a-z][0-9]{2}-psql-docker. If you rename the parent folder to say test2-psql-docker, docker compose will run without issue.

This is the error I get if parent folder is named j12-psql-docker:

~/j12-psql-docker
❯ docker-compose up
Recreating 85d224709979_j12-psql-docker_db-test_1 ... error

ERROR: for 85d224709979_j12-psql-docker_db-test_1  Cannot create container for service db-test: mkdir j12-psql-docker_db-data-volume: permission denied

ERROR: for db-test  Cannot create container for service db-test: mkdir j12-psql-docker_db-data-volume: permission denied
ERROR: Encountered errors while bringing up the project.

Output if parent folder name is test2-psql-docker (this is the expected result given the contents of docker-compose.yml and postgres image)

~/test2-psql-docker
❯ docker-compose up
Creating network "test2-psql-docker_default" with the default driver
Creating volume "test2-psql-docker_db-data-volume" with default driver
Creating test2-psql-docker_db-test_1 ... done
Attaching to test2-psql-docker_db-test_1
db-test_1  | Error: Database is uninitialized and superuser password is not specified.
db-test_1  |        You must specify POSTGRES_PASSWORD to a non-empty value for the
db-test_1  |        superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
db-test_1  |
db-test_1  |        You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
db-test_1  |        connections without a password. This is *not* recommended.
db-test_1  |
db-test_1  |        See PostgreSQL documentation about "trust":
db-test_1  |        https://www.postgresql.org/docs/current/auth-trust.html
test2-psql-docker_db-test_1 exited with code 1

If I rename the parent folder to p77-psql-docker:

~/p77-psql-docker
❯ docker-compose up
Creating network "p77-psql-docker_default" with the default driver
Creating volume "p77-psql-docker_db-data-volume" with default driver
Creating p77-psql-docker_db-test_1 ... error

ERROR: for p77-psql-docker_db-test_1  Cannot create container for service db-test: mkdir p77-psql-docker_db-data-volume: permission denied

ERROR: for db-test  Cannot create container for service db-test: mkdir p77-psql-docker_db-data-volume: permission denied
ERROR: Encountered errors while bringing up the project.

Information

  • Windows Version: Windows 10 Pro OS build: 19041.172 Version: 2004
  • Docker Desktop Version: 2.2.3.0 (43965)
  • Are you running inside a virtualized Windows e.g. on a cloud server or on a mac VM: No
  • WLS2: ubuntu 18.04

Steps to reproduce the behavior

Here is the gist I sent to a friend that was able to reproduce the error. He is also running the same version of docker-desktop. Below are hopefully easier steps to follow and a smaller docker-compose.yml file.

I also ran Clean / Purge data (checked off every option) and also ran Reset to factory defaults before doing the following steps.

  1. Make sure Docker Desktop has WSL2 integration turned on
  2. Start up WSL2 ubuntu 18.04 (no idea if this is specific to this distro, I don't have any others to test on)
  3. In your user home directory (not on a windows mounted drive. I haven't tested if it also breaks there or not) create the following directory j12-psql-docker.
  4. Create the following file files inside of that directory (This is different from the original gist. No .env file and a smaller docker-compose.yml file.

File: docker-compose.yml

version: "3.4"
services:

  db-test:
    image: postgres:alpine
    volumes:
      - db-data-volume:/var/lib/postgresql/data

volumes:
  db-data-volume:
  1. run docker-compose up if you don't have the postgres:apline image it'll download it first then fail with the following error:
~/j12-psql-docker
❯ docker-compose up
Creating network "j12-psql-docker_default" with the default driver
Creating volume "j12-psql-docker_db-data-volume" with default driver
Pulling db-test (postgres:alpine)...
alpine: Pulling from library/postgres
aad63a933944: Pull complete
a5b4c973b808: Pull complete
074a034a3a7a: Pull complete
48e4532f784a: Pull complete
4e7e92e65f6a: Pull complete
d5f366a1c147: Pull complete
b33682350b13: Pull complete
0204b658ab83: Pull complete
Digest: sha256:c52d4eac43883c53113cee0ebd1ce0fe53ef0604708822901ecca6655968fa9a
Status: Downloaded newer image for postgres:alpine
Creating j12-psql-docker_db-test_1 ... error

ERROR: for j12-psql-docker_db-test_1  Cannot create container for service db-test: mkdir j12-psql-docker_db-data-volume: permission denied

ERROR: for db-test  Cannot create container for service db-test: mkdir j12-psql-docker_db-data-volume: permission denied
ERROR: Encountered errors while bringing up the project.
  1. If you rename the folder from j12-psql-docker to something like test2-psql-docker and run docker-compose up again it'll work. It appears to only fail when the parent folder's name matches [a-z][0-9]{2}-psql-docker
  2. If you do the same but outside of WSL2 (on the same machine) you won't get the error. I also tested this on my linux laptop and was not able to reproduce the issue.

Powershell, same folder name and docker-compose.yml file:

PS D:\docker\j12-psql-docker> ls


    Directory: D:\docker\j12-psql-docker


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----          4/6/2020   2:01 PM            153 docker-compose.yml


PS D:\docker\j12-psql-docker> docker-compose up
Creating j12-psql-docker_db-test_1 ... done
Attaching to j12-psql-docker_db-test_1
db-test_1  | Error: Database is uninitialized and superuser password is not specified.
db-test_1  |        You must specify POSTGRES_PASSWORD to a non-empty value for the
db-test_1  |        superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
db-test_1  |
db-test_1  |        You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
db-test_1  |        connections without a password. This is *not* recommended.
db-test_1  |
db-test_1  |        See PostgreSQL documentation about "trust":
db-test_1  |        https://www.postgresql.org/docs/current/auth-trust.html
PS D:\docker\j12-psql-docker>

Inspecting the volume:

~/j12-psql-docker
❯ docker volume inspect j12-psql-docker_db-data-volume
[
    {
        "CreatedAt": "2020-04-06T17:37:56Z",
        "Driver": "local",
        "Labels": {
            "com.docker.compose.project": "j12-psql-docker",
            "com.docker.compose.version": "1.26.0-rc3",
            "com.docker.compose.volume": "db-data-volume"
        },
        "Mountpoint": "/var/lib/docker/volumes/j12-psql-docker_db-data-volume/_data",
        "Name": "j12-psql-docker_db-data-volume",
        "Options": null,
        "Scope": "local"
    }
]
@simonferquel
Copy link

Thanks for the report, I reproduced and was able to fix the issue. It will come in a future version :)

@stephen-turner
Copy link
Contributor

Wow, that is a really surprising bug!

@stephen-turner
Copy link
Contributor

Fixed in 2.3, closing this ticket.

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Jul 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants