Networking on both interface with docker

Hello everybody,

I’m not sure that it’s good place to post this message, but I can’t find the good one. I’m here because I need a little help/advice on docker app.

My application (run on my computer, which is on a network connected to internet), take data from a device which is on a network (today this network is connected to internet which is the same as on my PC), so there is no problems.

But I want to do the same if the device is on different network and not connected to internet (this mean, my PC where the application run isn’t on the same network as the device sending data)

For example, my PC is connected both to LAN1 and LAN2 (LAN1 is a network for devices and LAN2 network for internet access)

My question is: is it possible to create something like this ? So I can in a single application, take data from an interface (eth0) and send this data to another network (eth1)

Anyone have an idea on how I can achieve this ?

Thanks for your help,

Kind regards,
Florian.

Some ideas for traffic initiated by your containers:
– declare the default gateway on the host system to a gateway only reachable using LAN2
– use a proxy for outgoing communication in your container that is only reachable using LAN2

I hope someone else has a better idea :slight_smile:
I am currios how this one plays out!

My networks LAN1 and LAN2 has different IP (for interface LAN1 on my PC it’s 192.168.1.10 and default gateway is 192.168.1.1 / for interface LAN2 on my PC, it’s something like 10.10.1.10 and default gateway is 10.10.1.1)

To be more clear, I have one device with IP 10.10.1.20 and I want my docker application running on my PC, take data from this device and send it over the network (to a cloud service) using internet on LAN1

If anyone has other idea on how I can achieve this :wink:

To update the situation, I always need help on this subject, but I resolve a part of the issue.

I create a network name device_network using macvlan, and I try another macvlan network which name is internet_network (it’s the network from my provider box).

When i use BUSYBOX image, I can ping a device in device_network, I can also ping another PC in internet_network. But I can’t ping google.com or 8.8.8.8 (whereas the internet_network is connected to internet)

Maybe this is a problem due to ipconfig, but after many tries, I can’t really identify the problem.

If anyone can help me, should be great !

Thanks in advance,
Florian.