Hello,
another simple and useful solution to resolve this problem with Compose is to use “network aliases” : Networking in Compose | Docker Documentation
version: "3.7"
services:
api:
links:
- nginx:api.localhost
nginx:
With that aliases, “nginx” container will be reachable from “api” container on http://api.localhost.
No need to update “/etc/hosts” inside “api” container.