How can I setup a docker postgres container on DigitalOcean and connect to it?
I’ve created a droplet with docker pre-installed
I’ve pulled the official Postgres image and used the following command to run it
docker run --name postgres -e POSTGRES_PASSWORD=****** -e POSTGRES_USER=**** -d postgres
This image auto exposes the default Postgres port 5432
I can see the container running using: docker ps
but cannot connect to it
I’m using jetbrains datagrip sql client to connect. I’ve filled the ip host, user/password I’ve set on the Postgres container.
My droplet inclues my ssh keys and I could verify that I’m able to connect to my droplet but not to my container.
I assume I should use such a tcp client to connect to my droplet ip on 5432 port and I’m suppose to be able to connect to it, right?
Did I miss anything?
I’ve also tried setting up a network driver using:
docker network create --driver bridge postgres-network
and after stoping and removing the container to recreate it like so:
docker run --name db-postgres --network postgres-network -e POSTGRES_USER=**** POSTGRES_PASSWORD=****** -d postgres
It didn’t work either…
Can you please assist me?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×