I've recently moved copied my postgres data from one hard drive to another.

My docker run command is

    docker run --name postgres --restart=always -e 
 POSTGRES_USER= -e POSTGRES_PASSWORD= -e POSTGRES_DB=elevate_recruit -v /media/postgres:/var/lib/postgresql/data -d -p 543
2:5432 postgres:9.5

Where the media drive is a drive that contains the postgres backup. When I run ls -l media/postgres I get

drwxrw-rw-  6 sbt springcoil 4096 Jun 20 10:25 base
drwxrw-rw- 19 sbt springcoil 4096 Jun 21 13:27 data
-rw-rw-rw-  1 sbt springcoil    4 Apr 27 13:38 PG_VERSION

When I run the docker container and do docker logs container_id I get

postgres cannot access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory

Edit - the data/postgres.conf file exists.

Am I missing something should I be changing the docker permissions? Should I be changing something? I'm a bit stumped and frustrated by this error.


I've found the solution to this problem.

Firstly make sure to do sudo usermod -aG docker your_user and then log back in. Also make sure you've got chmod 777 and chmod -R your_user:your_user on your folders.

Finally there is actually an error in my docker run command. It should be -v /media/postgres:/var/lib/postgresql instead of -v /media/postgres:/var/lib/postgresql/data thanks to whoever on a Slack channel (Dave Challis I think) pointed this out.

  • 1
    just nothing that it's rarely ever a good idea to chmod 777. The problem is obviously a permissions problem. But making the files/folders available to all is a bad idea. – Bob Jan 30 '19 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.