timescaledb-docker-ha
timescaledb-docker-ha copied to clipboard
initdb: error: could not change permissions of directory
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 https://github.com/timescale/timescaledb-docker-ha/issues/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 https://github.com/timescale/timescaledb-docker-ha/issues/359#issuecomment-1695094508, 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.
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.
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.
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