Last active
December 9, 2019 09:23
-
-
Save klovack/6ec56cf1cd2f916595410981115feab7 to your computer and use it in GitHub Desktop.
Short shell script to create postgres and pgadmin4 container in docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir $HOME/.postgres-data | |
cd $HOME/.postgres-data | |
docker kill postgres pgadmin4 | |
docker rm postgres pgadmin4 | |
docker volume create --driver local --name=pgvolume | |
docker volume create --driver local --name=pga4volume | |
docker network create --driver bridge pgnetwork | |
cat << EOF > pg-env.list | |
PG_MODE=primary | |
PG_PRIMARY_USER=postgres | |
PG_PRIMARY_PASSWORD=my-secret-password | |
PG_DATABASE=graphql_demo | |
PG_ROOT_PASSWORD=my-secret-password | |
PG_PRIMARY_PORT=5432 | |
EOF | |
cat << EOF > pgadmin-env.list | |
PGADMIN_DEFAULT_EMAIL=your-email@example.com | |
PGADMIN_DEFAULT_PASSWORD=YourSecretPassword | |
SERVER_PORT=5050 | |
EOF | |
docker run --publish 5432:5432 \ | |
--volume=pgvolume:/pgdata \ | |
--env-file=pg-env.list \ | |
--name="postgres" \ | |
--hostname="postgres" \ | |
--network="pgnetwork" \ | |
--detach \ | |
postgres | |
docker run --publish 5050:80 \ | |
--publish 5443:443 \ | |
--volume=pga4volume:/var/lib/pgadmin \ | |
--env-file=pgadmin-env.list \ | |
--name="pgadmin4" \ | |
--hostname="pgadmin4" \ | |
--network="pgnetwork" \ | |
--detach \ | |
dpage/pgadmin4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment