1

I am trying to run a a project with docker-compose and I am getting mkdir: cannot create directory ‘/home/postgres/pgdata/data’: permission denied. This problem only occurs on windows, on macOS the setup works fine. I think it has to do with user permissions on windows for docker.

The compose config:

volumes:
  volume_name:
    name: data

  postgres:
    container_name: postgres
    image: timescale/timescaledb-ha:pg14.7-ts2.10.2-latest
    ports:
      - "5433:5432"
    volumes:
      - ./data:/home/postgres/pgdata
    env_file:
      - ./.envs/.local/.postgres

Any idea what I could do to fix this? Thanks in advance, help is much appreciated

7
  • 1
    First try creating a data directory in your ./data directory, so Postgres doesn't need to do it. Commented May 8, 2023 at 9:35
  • @HansKilian Thanks! I updated my question with the volume creation. During the docker up process this directory gets created automatically with all files in it. Do you mean I should map the data directory to /home/postgres/pgdata/data instead of /home/postgres/pgdata? Commented May 8, 2023 at 9:48
  • 1
    Change - ./data:/home/postgres/pgdatato - data:/home/postgres/pgdata. Remove ./. Commented May 8, 2023 at 9:49
  • @kometen Thank you! But changing the path results in "data:/home/postgres/pgdata:rw" is used in service "postgres" but no declaration was found in the volumes section. Commented May 8, 2023 at 9:50
  • 1
    Changing it from ./data to data makes it a volume instead of a bind mount Commented May 8, 2023 at 9:54

1 Answer 1

0

You've insufficient rights to create the folder, which happens upon starting the container, as you provided:

...
    volumes:
      - ./data:/home/postgres/pgdata
...

You can solve it by removing the bind volume, then just start the container.

This may be caused by the fact, you already have the pgdata, and the container tries to create it. In this case, bind the volume to the pgdata folder instead, which should be located inside your data. Or bind the volume to a different folder, and it is going to create the pgdata on it's own

More on this subject

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.