How to expose locally dockerized postgres service to the net

380 Views Asked by At

Context:

I'm building a full stack project and have decided to deploy my services on docker, I have 3 services at the moment, database-service, frontend-service, and backend-service, in addition to postgres and pgadmin.

I have set up a docker-compose file and have ran all the services.

But, at some point, I have added Prisma to my database-service and some Prisma-Docker-Apple Silicon problems have started to prevent me from build and running my database-service in the localhost.

What I decided is to build my docker image for database-service on the cloud, at fly.io.

The Issue:

As I said before, I have decided to work with Prisma on my database-service, so in my prisma.yml, I should provide my postgres link. I have tried to expose my 5432 port to the internet using ngrok, but it didn't work.

If you have encountered a similar issue, please let me know how you could resolve this conflict. thank you!

1

There are 1 best solutions below

0
madhead On

You should use ngrok tcp 5432, and not ngrok http 5432.

I've started a PosgreSQL using docker run --name so75297011 -e POSTGRES_PASSWORD=so75297011 -d -p 5432:5432 postgres:latest. Don't forget about the ports when running PostgreSQL in Docker!

And exposed it via ngrok: ngrok tcp 5432. Got a tunnel: tcp://0.tcp.eu.ngrok.io:10821 -> localhost:5432.

Here is the result, connection successful

enter image description here