I have an Android app that needs some micro-services to be running to be able to work correctly. So each micro-service (when started correctly) opens a specific port on localhost and listen on it. All the services are dockerized.
So currently, I have created a docker-compose files with all the necessary micro-services. A typical micro-service looks like this:
my_service: image: my_docker_registry_url/my_service:latest ports: - 4002:4002 environment: ... restart: unless-stopped logging: driver: json-file options: max-size: "200k" max-file: "10" depends_on: ...
In the snippet above you can see the port mapping I use in my docker-compose file.
So anyway, what I do then is to run ‘docker login …’ and ‘docker-compose up -d’ to start the services.
The problem I’m having is that the ports that are opened by the services are opened on the host and not inside the container. So inside the container ‘localhost:4002’ is not accessible.
On the host machine, however, ‘localhost:4002’ is accessible, but I don’t have any means to connect to it from within the container. Even if I did have a way, it’s not exactly a good solution. Because I’ll have port conflicts if I try to run concurrent builds on bitrise.
So the question I’m asking here is:
Is there a possibility of making each container(build) have it’s own network separate from the host and that when I start the services in each container the ports are mapped to that container’s network and not the host machine?
Please let me know if you have any questions or anything is unclear.