How do I setup the docker-compose file to connect to an internal containers network, and to the outside localhost network?
I tried to use the extra_hosts property within the docker-compose but could not get the result I need
My docker-compose contains the following:
version: '3.7'
services:
myapp1:
container_name:
myapp1
hostname:
myapp1
build:
context:
.
dockerfile:
Dockerfile
command:
["npm", "start"]
networks:
- container_network # This is an internal container network
myapp2:
... # Same idea as above
networks:
- container_network # This is an internal container network
networks:
container_network:
name:
container_network
driver:
bridge
I also have an standalone service, and I run it with the following command:
docker run --name standalone_service --network host
There are other reasons, that are irrelevant to my question, why the standalone_service cannot be merged into the docker-compose file. Therefore, merging it into the docker-compose file and using the container_network is not an option for this service.
I want myapp1, which is part of the internal container_network, to be able to access standalone_service which is on the host network. How do I do this?