DEV Community

Peter Cooper
Peter Cooper

Posted on

How to Quickly Play with PostgreSQL 15 Beta using Docker

The first beta of Postgres 15 is out now and the official Docker image for it has also just gone live, making it easy for you to take it for a quick spin without destroying your production systems.

Assuming you have Docker running, here's the quickest way to get going:

docker network create pgnetwork
docker run --name pg15beta1 --network pgnetwork -e POSTGRES_PASSWORD=whatever -d postgres:15beta1 
Enter fullscreen mode Exit fullscreen mode

This creates a network called pgnetwork so that other containers can communicate with Postgres easily. A container is then run based on the postgres:15beta1 image, a default password is set for the postgres user (you can change this to whatever you like), and the container is given the name of pg15beta1.

Then to run psql:

docker run -it --rm --network pgnetwork postgres:15beta1 psql -h pg15beta1 -U postgres
Enter fullscreen mode Exit fullscreen mode

This spins up another container (which is deleted after you quit psql thanks to the --rm option) which uses the same Postgres image but to run psql instead. Enter the password you provided in the first step and you're in.

Everything is working with psql

To clean up:

docker stop pg15beta1
docker rm pg15beta1
Enter fullscreen mode Exit fullscreen mode

If you have psql locally and want to experiment with Postgres 15 with apps on your local system, you could expose its port on localhost like so:

docker run --name pg15beta1 -e POSTGRES_PASSWORD=whatever -p 1234:5432 -d postgres:15beta1
Enter fullscreen mode Exit fullscreen mode

This then makes the Postgres 15 server accessible at port 1234 on localhost. Tweak to suit your use case.

Discussion (2)

Collapse
alilosoft profile image
Ali FELLAHI

to the point, nice 👍

Collapse
andrewbaisden profile image
Andrew Baisden

Nice thanks for the news update!