All jobs / DevOps / SRE / cloud / Containers

DevOps / SRE / cloud interview question · 1–3 years

The app container connects to `localhost:5432` and gets connection refused, though the database container is running. Why?

The strongest answer

Each container has its own network namespace, so localhost is the app container itself; on a Compose or user-defined network the containers resolve each other by service name — connect to `db:5432`

Why it works

Exactly — container networking gives each container its own loopback and embedded DNS by service name.

What a good answer covers

Answers that fall short

Who gets asked this

More Containers questions