You can easily run postgreSQL and pgAdmin UI interface on windows WSL as docker containers. You can install WSL on windows using this link.
PostgreSQL DB in Container
You can now run Postgres in docker container with simple command which will create a container and expose the port used by Postgres so it can be accessed from the host.
docker run -p 5430:5432/tcp --name postgres-dev -e POSTGRES_PASSWORD=postgres -d postgres docker run -p 5431:5432/tcp --name postgres-test -e POSTGRES_PASSWORD=postgres -d postgres
here 2 containers will be started, one for dev (postgres-dev) setup and one for test (postgres-test) setup. The containers will show up like below
pgAdmin UI Interface in Container
Now to connect to these databases, we will run pgAdmin UI interface in container using the below command-
docker run -p 8080:80 -e 'PGADMIN_DEFAULT_EMAIL=admin@test.com' -e 'PGADMIN_DEFAULT_PASSWORD=pgAdmin' -d --name=ui-pgadmin dpage/pgadmin4
here pgAdmin container exposes on port 8080. Once ui interface is started, it will have a container running as shown
Now we can access pgAdmin UI interface. Open browser and type localhost:8080
It will connect to pgAdmin and show this page with successful login-
Now you can add connection to DEV and TEST postgres DB.
You are now connected to both DEV and TEST postgreSQL databases which are running in container.
You can stop and start these containers as and when required.
Persist PostgreSQL DB
In case you want to remove the container to start new version of postgreSQL and still want to have all the users, databases and other objects then use data volume container to achieve this. Using the below command start the data volume container
docker create -v /var/lib/postgresql/data --name postgresContainerData alpine
Now you can start the postgres database container by attaching this volume container to it. This way even if the postgres container is removed, the data container will be available to attach to new postgres server container-
docker run -p 5430:5432/tcp --name postgres-dev -e POSTGRES_PASSWORD=postgres -d --volumes-from postgresContainerData postgres