App overview screenshotSQL and Database Guides
PostgresMySQL
Try our free SQL Client
Tools
Connecting to Postgres
Connecting to drivers
Installing Postgres
Setting up Postgres
Postgres   >   
Installing Postgres   >   
Postgres and Docker on Linux

Connect to Postgres in Docker on Linux

Get The Container

Let's see if we can complete these steps by using our intuitive knowledge of docker. First, grab a clean docker image.

docker pull postgres

Download the PostgreSQL docker image

Check that you have it by running docker images and seeing it listed there.

Run The Docker Postgres Container

The Postgres container provides a very nice warning to set the master password for the database. Let's also make sure to expose 5432 from inside the container. If you have multiple databases or containers running you may want to choose a different host machine port, for example 2345.

docker run -d -p 2345:5432 -e POSTGRES_PASSWORD=getarctype postgres

Now, you can run docker ps to check that it is running and active:

Check that the PostgreSQL container is running.

Connect to PostgreSQL in Docker

For a fresh Postgres database, the default user is postgres and the default database is also postgres. Use that plus the port and password you entered above. On most systems, the docker networking is in the Host configuration which means the database is available on localhost:

Successfully connect to Postgres in Docker.

Click Test Connection and then Save and you're done!

Want to ask for help on databases or SQL? Join our Discord community.