Docker containers can be binded to multiple interfaces
Each interfaces comes with a dynamic IP address.
Think about following scenario:
In your Docker compose file you specified your DB and Web service.
You bind DB to internal network interface.
You bind your web service to both your internal network interface and external interface.
You want your Web service only bind to external interface.
How do you do that?
Sample Docker compose file:
|
|
What should be put in server_host
if I don’t like 0.0.0.0
?
Would be interesting to investigate.
Answer:
One may simply bind the web server to “external” network by looking up the available links using something similar to ip addr
.
Meanwhile it is possible to assign static IP to a container.