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.

@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