How could I solve the following issue:
- Docker-compose project runs two containers with exposed ports
The containers can communicate with each other using dockers internal dns name, that I can pass as an environment variable, this is ok. Microservice
reaches File-Server
by dockers DNS name compose-project_file_server:80
From a dev machine I can reach both via localhost:5555
for File-Server and localhost:9999
for Microservice.
Now I am testing a piece of software that actually does a curl to the file server and if this is ok, delegates the job to the microservice. Except it does not work that way.
But after I got a 200 from a plain curl, the software automatically does the next step, which fails:
This cannot work, because Microservice cannot reach File-Server
via localhost:5555
, only via compose-project_file_server:80
My dev machine on the other hand cannot reach compose-project_file_server:80
.
What are my options here? I cannot meddle with my dev machine hosts file because the ports are still wrong, and it also feels wrong.
In production this entire scenario is unlikely, the File-Server exists only in an integration-test scenario setup, but it is necessary for various verification steps.
Is there a way to actually bind File-Server:80
inside Microservice to localhost:5555
as well for integration tests?