Routing containers on same host into several wans

Hello,

I’m wondering if there is a way to do this feature.

My network is using a opnsense router and has 2 internet connection (ISP and 4G).
LAN Network is 172.16.0.0/16, I can easily route traffic from computers from this lan by adding rules in this router regarding their ip (for instance 172.16.0.5 goes to ISP and 172.16.0.6 goes to 4G)

I have a dedicated computer on the LAN that run a docker host. Lets say its IP is 172.16.0.7

Lets say now I have 2 containers A and B running on this host with their own network and ip (docker stacks), for instance 172.17.0.4 and 172.18.0.4. Of course those IP are only accessible from docker host, the router does not know anything about them.

My question is, is there a way to route the trafic concerning A into ISP and concerning B into 4G ?

I believe it is more a network question (how to make visible those 2 networks on my LAN) than a docker question, but in case there is something that can be done on docker side and help this, I just need some hints, I can then dig then on tutorials and docs if I have something to focus on.

Many thanks for your time.

For clarification, here is an extract of network configuration section in the docker-compose.yml I’m using for both stacks A and B (172.18.0.0 and 172.17.0.0 for the 2 files)

networks:
default:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.17.0.0/16