pgAdmin on Docker/Ubuntu 18

2019-10-15

Introduction

pgAdmin is a web based admin tool for Postgresql which can be found here: https://www.pgadmin.org/. It is a useful tool for people (read me) who can't always remember the psql syntax when troubleshooting a database.

This post will quickly show how to set up an Ubuntu 18 in a virtual machine, install Docker and set up pgAdmin with a persistend volume. If you are already familiar with Vagrant Kitchen (my take on integrating Vagrant with an ansible inventory), you should be able to do this in about 5 - 10 minutes.

Installation

The installation is divided into two steps:

On your laptop/workstation

Create a Vagrant kitchen inventory. You need to have vagrant kitchen set up before you start this. See: https://git.kmg.group/oss/vagrant-kitchen

[vagrant-kitchen]
pgadmin ansible_ssh_host=192.168.110.118 vagrant_image=kmggroup/soe-linux-u18  vagrant_ram=2048 vagrant_cpu=4 ansible_user=vagrant ansible_password=vagrant
vagrant up pgadmin

In the new Ubuntu 18 VM

When the VM is started, connect to it:

vagrant ssh pgadmin
sudo apt-get update
sudo apt-get install  -y   apt-transport-https     ca-certificates     curl     gnupg-agent     software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
sudo apt-get -y install docker-ce docker-ce-cli containerd.io
cat<<EOT > pgadmin-env.list
PGADMIN_DEFAULT_EMAIL=m@kmggroup.ch
PGADMIN_DEFAULT_PASSWORD=P@ssw0rd
EOT
sudo docker pull dpage/pgadmin4
sudo docker volume create --driver local --name=pga4volume
sudo docker run -p 80:80 --env-file=pgadmin-env.list --volume=pga4volume:/var/lib/pgadmin dpage/pgadmin4

You can now visit the pgAdmin GUI on your newly installed docker image on http://192.168.110.118 (see IP address in your vagrant-kitchen inventory).

References