How to Connect Docker PostgreSql

Most of us use docker for day to day development tasks. Docker can be useful but problematic for beginners. Today we are going to discuss how to connect docker PostgreSql database.

In this article I will use dbeaver as the database client. If you didn’t hear about dbeaver before it is an open source database client, with a very clear UI and runs on most of the popular operating systems.

Connecting to a Docker Postgresql Server

Before understanding how to connect docker PostgreSql, i would like to show you, how i create a server container on docker.

docker run --name mypgserver -e POSTGRES_PASSWORD=passw0rd -p 5432:5432 -d postgres 

The command above creates a container which runs PostgreSql server, with the latest released version. Default database name is postgres and passw0rd is the password for user postgres.

As you can see above, command created a PostgreSql container. Now we can proceed to how to connect Docker PostgreSql topic.

Connect to PostgreSql with Dbeaver

Start dbeaver. If you are running it for first time tool will ask if you want to create a sample database or not. You can create and discover it’s features but i will click no.

You can use button on top left or right click to database navigator pane and click create -> connection button.

Connection wizard very straight forward. You can see how many database engines are supported by dbeaver.

Select PostgreSql and click next.

On this screen, you only need to update password with passw0rd value to connect. Click Test Connection button from bottom left of the wizard and let it test connection. After you succeed you can click finish and close the wizard.

If you are connecting to a database engine type for first time, dbeaver itself connects to driver repository and download required jdbc driver and other jar files from internet. To use this feature internet connection is required.

In the screenshot above you can see test connection result. Click OK and click finish to close wizard.

To Sum Up

As you can see connecting to PostggreSQL Server running on a Docker container is pretty straightforward if port is mentioned.

A new post everyday, subscribe now and don’t miss it!

Subscribe to our newsletter for cool news

Hi! I’m an IT Specialist

I want to hear from you! I am Working with enterprises for 10+ years to improve their infrastructure and efficiency.

Get in touch with me.

Leave a Reply

Discover more from Empower. Innovate. Transform.

Subscribe now to keep reading and get access to the full archive.

Continue reading