Skip to content

Instantly share code, notes, and snippets.

@samsch
Last active January 20, 2021 22:19
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save samsch/a8a9c81a12cf35fe123ba063a5ecdf33 to your computer and use it in GitHub Desktop.
Save samsch/a8a9c81a12cf35fe123ba063a5ecdf33 to your computer and use it in GitHub Desktop.
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.

@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

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