I'm using docker compose and one service runs NGINX. Inside its configuration I need the IP address of another service/container. I already found this which describes how to use env variables in nginx config files. However, the problem I have now is how to get an IP address of a service inside another service?
version: "3.9"
services:
webserver:
environments:
- API_HOST: api
...
api:
...
This is what I tried, but this will not result in an environment variable with an IP address. The contents of the $API_HOST will just be api
.
So my question is, how can I do this. In that post I mention above there is also a solution to have a custom entrypoint script, so I can execute commands on startup inside the nginx container! Any suggestions?