14

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?

Qwertie
  • 1,234
  • 3
  • 14
  • 28

1 Answers1

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

$ 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.

postgres=#

You forgot the -U postgres

wgl
  • 121
  • 3