My Goal
I have a web frontend application which communicates via a specific port (REST API) with a backend application (lets call it "My_App"). My_App needs to send Multicast frames to communicate with something in the outside world. And I need to put everything into Docker Containers.
What I tried (and failed)
First I tried to have nginx and the app inside a single Container using host networking for the whole Container. Like depicted in the following picture:
This works on my developement PC but does not on the target system due to some firewall rules preventing me from accessing Port 8081 and 12345 from outside the target system. If I log into the target system e.g. via ssh I can access those Ports just fine. So the situation on the target system is like that:
What I am trying to achieve
So now I am trying to split the app and nginx into separate Containers (Port Mapping for bridged networks is allowed on the host system and I can access maped Ports from the outside).
What I want to to do is connect a Container A
using Bridge Networking with another Container B
using host networking, so that an Application (e.g. Nginx as reverse Proxy) inside Container A
can send Requests to Container B
on a specific Port. Something like shown in the following picture:
But now I do not know how to achieve this. I know that I can communicate between Containers if both are using bridge Networking by using Dockers DNS and the name of each Container. But how to do this if one Container uses host networking, bypassing Dockers DNS?
Here is my current docker-compose file:
version: "2"
services:
Container_B:
image: my_app
network_mode: host
Container_A:
image: nginx:alpine
ports:
- 80:8081
- 12342:12342 // apparently does not work because in use by Container_B
depends_on:
- "Container_B"
The actual question
Is it possible to access a Port, inside a Container_B
using host networking, from within a Container_A
using Bridge networking? Without some external application doing the routing?