Quotidien Shaarli
08/12/24
On my postgresql docker image :
initdb: error: could not access directory "/home/postgres/pgdata/data": Permission denied
I reused a previous image
volumes:
- pgsql_data:/data/pgsql
environment:
PGDATA: /data/pgsql
So actions :
- start image without setting PGDATA, then execute :
Then :
docker exec myimage id # to check the user (here 1000:1000)
docker exec myimage ls -l /data/ # to check the mount directory
docker volume inspect pgsql_data # give the path of the volume
// update the rights
chown 1000:1000 -R /home/docker/volumes/pgsql_data
- stop
docker compose up pgsql
- restore PGDATA parameter
- restart
docker compose up pgsql
Another docker command :
docker cp <containerId>:/file/path/within/container /host/path/target
But can not use joker characters like "*"