Created
January 3, 2018 10:33
-
-
Save sebbarg/b75e3b2803a20cbaf2c3f53d53f920ae to your computer and use it in GitHub Desktop.
Linux/Docker: connect pgadmin4 to postgres running on the local host (not in a container)
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
#!/usr/bin/env bash | |
set -o nounset -o pipefail | |
# | |
# - When running this script pgadmin4 is available at http://localhost:5050 | |
# - Postgres is tunneled through SSH and available to pgadmin4 (and anything else) | |
# at pghost:54320 | |
# | |
# - Container: https://github.com/thaJeztah/pgadmin4-docker | |
# | |
VOLUME="/home/seb/pgadmin:/pgadmin" | |
ADD_HOST="pghost:192.168.1.100" | |
# | |
# Put below in ~/.ssh/config: | |
# Host pgadmin4-proxy | |
# HostName localhost | |
# ControlPath ~/.ssh/pgadmin4-proxy.ctl | |
# | |
ssh -f -N -T -M -L 0.0.0.0:54320:localhost:5432 pgadmin4-proxy | |
# Start pgadmin4. CTRL-C will tear down pgadmin4 and eventually tunnel. | |
docker run \ | |
--rm \ | |
--publish 5050:5050 \ | |
--name pgadmin4 \ | |
--volume $VOLUME \ | |
--add-host $ADD_HOST \ | |
thajeztah/pgadmin4 | |
ssh -T -O "exit" pgadmin4-proxy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment