I started a postgres docker container using

sudo docker run --name some-postgres -d postgres

and then attempted to connect to it using

sudo docker run -it --rm --link some-postgres:postgres postgres psql -h postgres

which gives the error psql: FATAL: role "root" does not exist

These commands are exactly the same as the ones listed on the docker hub page Only run as root and without -e POSTGRES_PASSWORD=mysecretpassword

Have I done something wrong here? What could be causing this?

$ docker run --rm --name some-postgres -d postgres

$ docker run -it --rm --link some-postgres:postgres postgres psql -h postgres -U postgres
psql (10.4 (Debian 10.4-2.pgdg90+1))
Type "help" for help.


You forgot the -U postgres

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.