Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Run a postgres container and connect with pgadmin (in another container)

Start a postgres server:

docker run -v postgres:/var/lib/postgresql/data --name postgres-test -e POSTGRES_PASSWORD=mysecretpassword -d postgres

Start pgadmin

Connect with a one-off docker container in current process:

docker run -v pgadmin4:/home/pgadmin/.pgadmin -p 5050:5050 --link postgres-test:postgres-test --rm meedan/pgadmin

Connect with a persistant docker container as background process:

docker run -v pgadmin4:/home/pgadmin/.pgadmin -p 5050:5050 --link postgres-test:postgres-test --name pgadmin -d meedan/pgadmin

You can stop with docker stop pgadmin and restart with docker start pgadmin. Just make sure the postgres container is running as well.

Connect to DB

Open http://localhost:5050. Add server, and use postgres as hostname, postgres as user, and mysecretpassword as password.

@asfilo
Copy link

asfilo commented Dec 3, 2017

When connecting to the DB I believe the hostname should be postgres-test (not postgres). Otherwise, this worked great. Thanks.

@carolgit
Copy link

carolgit commented Dec 11, 2017

Login page ask for email, and no email is set can you tell me how to log-in?

@mungale
Copy link

mungale commented Dec 20, 2017

PGADMIN_USER for user name (default value is admin@pgadmin.org)
PGADMIN_PASSWORD for password (default value is pgadmin)

@WhatFreshHellIsThis
Copy link

WhatFreshHellIsThis commented Jan 8, 2018

Very cool, but it says your pgadmin is out of date

@samsch
Copy link
Author

samsch commented Jun 1, 2018

Thanks for the interest. This gist is a little out of date, though it should still work if you use the correct hostname as noted by @asfilo, and you login with the default email and password noted by @mungale.

I'll create and upload a new gist in the future if or when I start using this approach again, but for the time being I use the pgadmin available in the Ubuntu Apt repositories.

@hakuno
Copy link

hakuno commented Jul 23, 2019

Now you can use --network parameter or so. Look at here.

@samsch
Copy link
Author

samsch commented Jul 23, 2019

@hakuno Thanks! I'll keep that in mind if I start using this again. If this is something you use regularly, please feel free to write a new gist or fork this one, and I'll update this one to link to it.

(Off-topic: Thank you Github for finally making gist comments notify me!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment