Skip to content

Instantly share code, notes, and snippets.

@p4prawin
Forked from tcoupin/Setup Pgadmin4 docker.md
Created February 28, 2024 13:32
Show Gist options
  • Save p4prawin/5bacaf27e4bc6d438cac9f78814d2ffd to your computer and use it in GitHub Desktop.
Save p4prawin/5bacaf27e4bc6d438cac9f78814d2ffd to your computer and use it in GitHub Desktop.
Setup Pgadmin4 docker

Just run:

curl https://gist.githubusercontent.com/tcoupin/af82bbbf5de516d186c1f2170ae5d0c4/raw/setup.sh | bash

Notes:

  • on close, the container is not close.
  • default email : [email protected], default password admin
  • a volume named "pgadmin" is create to store config
  • don't use '127.0.0.1' to access host, use the bridge gateway (default 172.17.0.1, get real ip docker inspect -f '{{range $key, $value := .NetworkSettings.Networks}}{{printf "%s" $key}}->{{.Gateway}}{{end}}' pgadmin)
#!/bin/bash
docker pull dpage/pgadmin4
cat << EOF > /tmp/pgadmin4
#!/bin/bash
docker run --name pgadmin --rm -p 54321:80 \
-v "pgadmin:/var/lib/pgadmin" \
-v "$HOME:$HOME" \
-e "[email protected]" \
-e "PGADMIN_DEFAULT_PASSWORD=admin" \
-d dpage/pgadmin4 || true
(nohup xdg-open http://127.0.0.1:54321 >/dev/null 2>&1)&
EOF
cat << EOF > /tmp/pgadmin4.desktop
[Desktop Entry]
Name=pgAdmin 4
Comment=PostgreSQL Administration Tool
Exec=pgadmin4
Terminal=false
Type=Application
Icon=pgadmin4
Categories=Development;Database;
Keywords=PostgreSQL;SQL;
EOF
wget -O /tmp/pgadmin4.png https://raw.githubusercontent.com/postgres/pgadmin4/master/web/pgadmin/static/img/logo-128.png
chmod a+x /tmp/pgadmin4
sudo mv /tmp/pgadmin4 /usr/local/bin/pgadmin4
sudo mv /tmp/pgadmin4.png /usr/share/pixmaps/pgadmin4.png
sudo mv /tmp/pgadmin4.desktop /usr/share/applications/pgadmin4.desktop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment