I’m running into issues connecting to a Postgres service. My service file looks like this:
postgres: image: postgres:11 ports: - 5432:5432 env: POSTGRES_PASSWORD: "some_pass" POSTGRES_DB: "some_db" options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
My code is configured to talk to postgres when connecting to the database, but I’m getting the following error:
could not translate host name "postgres" to address: Temporary failure in name resolution
This reads like it’s unable to resolve “postgres” to anything useful. I’ve tried switching it to “database” and “my_database” (trying something non-generic) and everything gets the same issue. When I look at the container initialization, it seems like its doing the right thing (pulled and formatted from the logs):
/usr/bin/docker create --name << SOME HASH >> --label dd9e73 --network github_network_<< HASH >> --network-alias postgres -p 5432:5432 --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 -e "POSTGRES_PASSWORD=some_pass" -e "POSTGRES_DB=some_db" -e GITHUB_ACTIONS=true postgres:11
The one thing I’m not doing that all of the examples do is inject the database port. I’m not doing that based on the -p 5432:5432 option that’s being passed in. I also wouldn’t expect a port issue to be cropping up as a name resolution error.
Any ideas as to what I’m missing?