Interview Prep/Docker/Networking, DNS and Compose

`curl: (7) Failed to connect to localhost port 8080: Connection refused` after `docker run -p 8080:80 nginx`.

BeginnerTroubleshootingNetworking, DNS and Compose
Answer

Likely causes → Container not running, mapping reversed (-p 80:8080), app listening on another port or only on loopback, or the request is from another host while docker is remote.

Diagnose →

docker ps
docker port web
docker exec web ss -tlnp
ss -tlnp | grep 8080

Fix → Use -p hostPort:containerPort correctly, bind 0.0.0.0 in the app.

Prevent → Verify with docker port after starting.

All Docker questions Roadmap: Docker & containers

More on Networking, DNS and Compose