A job sets 'container: node:20' and a service 'postgres'. From a step inside the job container, which hostname should connect to PostgreSQL?
Select an answer to reveal the explanation.
Short Explanation and Infographic
When the job runs inside a container, service containers are reachable by their service id hostname on the Docker network—not localhost.
Full explanation below image
Full Explanation
In container jobs, GitHub attaches services to the same Docker network and DNS-resolves the service key name (postgres) to the service container. localhost inside the job container refers to that container itself, not the sidecar. Non-container jobs on Ubuntu often use localhost with published ports instead. host.docker.internal is not the primary documented pattern for Actions service connectivity on Linux-hosted runners. There is no services.postgres.github.com hostname. Document connection strings per job shape to avoid flaky CI.