Using static IP addresses for the containers seems suspicious and unnecessary:
https://github.com/debiki/talkyard-prod-one/blob/master/docker-compose.yml#L19
I don't see why you can't use service names or aliases:
https://docs.docker.com/compose/compose-file/compose-file-v3/#aliases
But again I may be wrong, since I don't know all the details.
- KajMagnus @KajMagnus2021-03-29 15:49:47.951Z
There's an explanation about the IP addresses in the
.env
file:
https://github.com/debiki/talkyard-prod-one/blob/895b7aa6e2deee5dac0e9551d278a4d6195136de/.env#L28Talkyard did use hostnames / aliases previously, but then Docker, after the restart of one container, sometimes gave it a new IP address, causing problems when the other containers, or [OS or Talkyard web / app server components] in those other containers, didn't notice that the IP address had changed.
(For example, if I remember correctly, requests from the Web container to the App container, could fail, for no obvious reason, after the App container had gotten restarted. Didn't happen often, but sometimes.)
The IP addresses are private, in an internal Docker network, not accessible from outside.
- Dashamir Hoxha @dashohoxha
(For example, if I remember correctly, requests from the Web container to the App container, could fail, for no obvious reason, after the App container had gotten restarted. Didn't happen often, but sometimes.)
I think that from the web container you can refer to the app container using the hostname
app
, for example like this:http://app:9000
, instead of using an IP. I don't see why this should fail, unless Docker has some bugs and doesn't work as expected.Anyway, you know it better than me.
- KajMagnus @KajMagnus2021-03-31 14:19:10.308Z
Yes, that's how it's done :- ) in server-locations.conf for Nginx: (as of April 2021)
proxy_pass http://app:9000/;
The thing is,
app
:s IP address will be the same, always. Otherwise, not often but sometimes (at least in the past), ifapp
got stopped / removed, and restarted, it could get a new IP address, but Nginx continued trying to access the old IP address (until the Web container got restarted, it too, and Nginx inside picked up the new IP).