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

initdb: error: could not change permissions of directory #460

Open
AlexanderProd opened this issue May 2, 2024 · 3 comments
Open

initdb: error: could not change permissions of directory #460

AlexanderProd opened this issue May 2, 2024 · 3 comments

Comments

@AlexanderProd
Copy link

AlexanderProd commented May 2, 2024

I'm using the latest timescale/timescaledb-ha:pg16.2-ts2.14.2-all Docker image, but I'm still getting the

initdb: error: could not change permissions of directory "/var/lib/postgresql/data": Operation not permitted
fixing permissions on existing directory /var/lib/postgresql/data ... %                                     

error like in issue #359 when providing the PGDATA env variable.

My docker-compose config looks like this:

timescaledb16:
    image: timescale/timescaledb-ha:pg16.2-ts2.14.2-all
    volumes:
      - timescaledb16_data:/var/lib/postgresql/data
    ports:
      - '5436:5432'
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      DB_NAME: xxxx
      PGUSER: xxxx
      PGPASSWORD: xxxx
      PGDATA: /var/lib/postgresql/data

volumes:
  timescaledb16_data: null

Like described in this reply #359 (comment), a workaround is to provide a local path for the volume and to manally set the permissions. And when I do it like this it works.

But that doesn't work when you want to let docker handle the directory.

Also I have noticed that when ever I run docker compose down and docker compose up a new anonymous volume is created. Even though I have provided a named volume in the dockercompose file and this is actually being used.

@AlexanderProd
Copy link
Author

AlexanderProd commented May 15, 2024

I found a workaround by mounting the volume to this path inside the container

timescaledb16_data:/home/postgres/pgdata/data

and not setting the PGDATA env. When configured like that, everything works fine.

@jeniceek
Copy link

I've ran into same issue. Check whether you have userns-remap in Docker. If so try to add userns_mode: "host" to service definition.

@fuomag9
Copy link

fuomag9 commented Aug 4, 2024

Same issue with the following:

services:
  timescaledb:
        container_name: timescaledb
        restart: always
        ports:
            - 5432:5432
        volumes:
            - ./data:/home/postgres/pgdata/data
        environment:
            - POSTGRES_PASSWORD=password
        image: timescale/timescaledb-ha:pg16

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

No branches or pull requests

3 participants