I’m trying to launch a postgres db via a docker container, but can’t seem to get a connection to it after it’s successfully launched.
The dockerfile itself is rather simple
FROM postgres COPY scripts /docker-entrypoint-initdb.d/ ENV POSTGRES_USER=postgres ENV POSTGRES_PASSWORD=<password> ENV APP_DB_NAME=<db_name> EXPOSE 5432 CMD ["postgres"]
My fly.toml file has gone through a few iterations, but is currently:
app = "db" primary_region = "lhr" [build] ignorefile = ".dockerignore" [http_service] internal_port = 5432 force_https = true auto_start_machines = true auto_stop_machines = false min_machines_running = 0 [[services]] internal_port = 5432 protocol = "tcp" [[services.ports]] port = 5432
I originally tried using the generated file from
fly launch, I’ve also tried setting the connection handler to the postgres specific “pg_tls” value.
Originally, the plan was to connect to the database with an api (also a docker container deployed to fly.io), but I couldn’t get it to connect properly, so decided to try and connect to it from pg-admin on my machine (also running in a docker container), but couldn’t get that to work either.
I’ll admit, at this point I’m a little lost. My endgame is to have a nodeJS api talking to the database. Being able to connect to it with an admin tool running outside of the fly network would be nice, but more importantly, I want to understand how to correctly configure the .toml file and where I’m going wrong.