Docker Community Forums

Share and learn in the Docker community.

Create a new server for postgres from pgadmin. hostname error

Hello guys,

I’m new at using docker hub desktop. I created:
To start pgadmin from terminal: Worked
docker run -p 5050:80
-e “PGADMIN_DEFAULT_EMAIL=user@domain.com
-e “PGADMIN_DEFAULT_PASSWORD=SuperSecret”
-d dpage/pgadmin4

docker run --name expressparts -p 5432:5432 -d
-e POSTGRES_PASSWORD=postgres
-e POSTGRES_USER=postgres
-e POSTGRES_DB=myExpressPartsDB
-v pgdata:/var/lib/postgresql/data
postgres

Then I tried to create a new server after I logged in to http://localhost:5050/browser/

The hostname should be my hostname on my mac which I got from the terminal command: hostname.

host name: Ahmedmac.local
But I got this error:

I tried lowercase and uppercase nothing worked. Any ideas guys?

May I suggest to switch to docker compose and leverage service discovery (basicly a network internal dns) to let pgadmin communicate with postgres? Service discovery is available in all user defined docker networks - but not in the default bridge network that containers use by default if no other network is specified.

Another option is to use legacy container links.
Since you already configured “–name expressparts” for the postgres container, you can use it to crate a link on the pgadmin4 container:

docker run -d \
  --name pgadmin \
  --link expressparts:db \
  -p 5050:80 \
  -e PGADMIN_DEFAULT_EMAIL=user@domain.com \
  -e PGADMIN_DEFAULT_PASSWORD=SuperSecret \
  dpage/pgadmin4

Then you can use either “expressparts” as hostname or the introduced alias “db”.

I strongly suggest to not use container links and switch to docker-compose instead.

update: accidently added parameter for --link to -p. Moved them to --link and re-added the real -p parameters from your example.