Your nginx container exits a second after it starts, and docker logs shows nginx: [emerg] host not found in upstream "app" in /etc/nginx/conf.d/default.conf:4 . nginx looks up every hostname in proxy_pass once, at startup. If Docker's DNS can't answer for app at that moment, nginx refuses to run at all.
This guide reproduces the error with nginx:1.30.6-alpine in front of traefik/whoami:v1.12.0 on Docker Engine 29.9.2, then fixes each cause. Every message below comes from that lab run on November 9, 2026. Plenty of people hit this. On that day the Stack Overflow question Docker Networking - nginx: [emerg] host not found in upstream had 302,677 views and stopped: [emerg] 1#1: host not found in upstream had 177,100.
The short version:
The app container must be running and attached to the same user-defined network as nginx when nginx starts.
The default bridge network has no container DNS. Create a network with docker network create and attach both containers.
Two Compose projects get two separate networks.…