0

I don't know if this makes any sense, but is it possible to use WiFi in host but only mobile broadband in a docker image?

1
  • Why was this question down voted? Is it off topic?
    – Ron
    Commented Dec 6, 2015 at 16:24

1 Answer 1

0

Firstly you have to use --net=host, then your network interfaces will be available in the container. You can see the difference below.

I couldn't find an easy way without setting up bridges, etc.

A workaround could be to set up two proxies on your host, each bound to one of the interfaces and than use these in the containers to route the traffic through a specific interface.

In the second command all interfaces of your host are listed:

$ docker run --rm -it ubuntu ifconfig
eth0  Link encap:Ethernet  HWaddr 02:42:ac:11:00:02  
      inet addr:172.17.0.2  Bcast:0.0.0.0  Mask:255.255.0.0
      inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:1 errors:0 dropped:0 overruns:0 frame:0
      TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:90 (90.0 B)  TX bytes:90 (90.0 B)

lo    Link encap:Local Loopback  
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:65536  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

$ docker run --rm -it --net=host ubuntu ifconfig
docker0 Link encap:Ethernet  HWaddr 02:42:73:a4:b5:12  
        inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
        inet6 addr: fe80::42:73ff:fea4:b512/64 Scope:Link
        UP BROADCAST MULTICAST  MTU:1500  Metric:1
        RX packets:9 errors:0 dropped:0 overruns:0 frame:0
        TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:0 
        RX bytes:612 (612.0 B)  TX bytes:648 (648.0 B)

enp2s0  Link encap:Ethernet  HWaddr e8:9a:8f:97:9e:45  
        UP BROADCAST MULTICAST  MTU:1500  Metric:1
        RX packets:0 errors:0 dropped:0 overruns:0 frame:0
        TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000 
        RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo      Link encap:Local Loopback  
        inet addr:127.0.0.1  Mask:255.0.0.0
        inet6 addr: ::1/128 Scope:Host
        UP LOOPBACK RUNNING  MTU:65536  Metric:1
        RX packets:26117 errors:0 dropped:0 overruns:0 frame:0
        TX packets:26117 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:0 
        RX bytes:45604847 (45.6 MB)  TX bytes:45604847 (45.6 MB)

wlp1s0  Link encap:Ethernet  HWaddr 38:59:f9:dc:2b:2e  
        inet addr:192.168.2.129  Bcast:192.168.2.255  Mask:255.255.255.0
        inet6 addr: fe80::3a59:f9ff:fedc:2b2e/64 Scope:Link
        UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
        RX packets:253776 errors:0 dropped:0 overruns:0 frame:0
        TX packets:155396 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000 
        RX bytes:288759357 (288.7 MB)  TX bytes:24846263 (24.8 MB)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .