Hello i have not understood the following :
-In the docker
world we have from what i understood :
- A port that the
application
exposes - A port that the container exposes for the application
- A port that the host maps the container port
So given these facts in a configuration of 2 containers within docker-expose
If:
app | Host Port | Container Port | App Port
app1 8300 8200 8200
app2 9300 9200 9200
If app2
needs to communicate with with app1
directly through docker-host
why would i use links ,since i still have to somehow hardcode in the environment of app2
the hostname
and port
of app1
(container_name of app1
and port
of container of app1
)?( In our example : port=8200
and host=app1Inst
)
app1:
image: app1img
container_name: app1Inst
ports:
- 8300:8200 //application code exposes port 8200 - e.g sends to socket on 8200
networks:
- ret-net
app2:
image: app2img
container_name: app2Inst
ports:
- 9300:9200
depends_on:
- app1
networks:
- ret-net
links:
- app1
///i still need to say here
/ environment : -
/ - host=app1Inst
/ - port=8200 --what do i gain using links?
networks:
ret-net: