• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Wifi in a Container
How can I use Wifi (in client mode) from within a container?

I'm using hilschernetpi/netpi-nodered-fieldbus:latest with Network=host and would like to connect to the cloud using Wifi instead of eth0.
What do I need to do to enable the Wifi within the container?
Hello Iotuser,

this is very easy. If you use the option "network=host" then docker starts the container using the same TCP/IP stacks as the Linux Host system. In this case it is not a matter of the physical interfaces eth0 and wifi any more, but just a matter of the ip addresses that you have configured.

So make a simple test:
If you configure the eth0 IP address of netPI to for example then you can reach the node-red under
If you now configure the wifi address of netPI to for example (in access point mode) and you connect your mobile phone to this wifi network getting then you can reach node-red under also.

You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

Hello Armin
Thanks for the fast response!

Accessing the node-red UI over Wifi works fine.
What I like to do is to connect my node-red to an Azure IoT Hub using the Wifi connection which fails with a "EHOSTUNREACH" error (using https 443 as outgoing port) .
The same scenario using eth0 worked fine. Any additional configuration required for this?

Best Regards
Hello iotuser,

just to understand it right. You have a Wifi network active and a router that is providing an IP address to netPI over Wifi. Is that correct? In this case netPI operates as a "Wifi Client"

Now you have two networks in netPI active. eth0 and wlan0. In both configuration settings you will have next to the ip address, also a subnet mask and also a gateway active, right?

Now if the node-red container wants to "send something" it has two interfaces eth0 and wlan0 where he is able to send it, but now he does not know which interface shall be used for sending out data. Linux in this case does it in a very practical way: it uses the first interface that has a gateway address and sends data across this one found first. In your case it will be eth0.

So in order to get data be sent across wlan0, you have to delete the gateway address of interface eth0. Then linux will use the gateway of wlan0 address instead and will send your data over your Wifi router

You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

Hello Armin

Deleting the Gateway address solved the issue.
Thanks a lot! I knew it must be something stupid...

Thank you for your feedback
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)


Possibly Related Threads…
Thread Author Replies Views Last Post
  NetPI WiFi through Internet DSongra 1 1,038 September-7th-2021, 07:54 AM
Last Post: Armin@netPI
  NetPI wifi access to WPA2-Enterprise MikeP 4 2,023 September-3rd-2021, 02:56 PM
Last Post: MikeP
  TOSILOCK for CONTAINER COswald 3 923 July-13th-2021, 11:32 AM
Last Post: Armin@netPI
  Access to RTC from my own container application tad 1 1,728 March-19th-2021, 02:58 PM
Last Post: Armin@netPI
  [SOLVED] Starting services/commands/scripts at startup of a container Jonas.Sellmann@outlook.de 9 3,312 March-9th-2021, 08:47 AM
Last Post: WalterSchaefer
  wifi MAC is changing j.langlois 3 1,420 January-26th-2021, 04:23 PM
Last Post: Armin@netPI
  OpenVPN container Armin@netPI 0 868 January-3rd-2021, 12:13 PM
Last Post: Armin@netPI
  operating Console of a container on netPI connected to Wi-Fi tethering tad 3 1,396 December-3rd-2020, 12:32 PM
Last Post: tad
  NIOT-E-NPIX-4DI4DO with netpi-netx container WalterSchaefer 3 1,694 November-25th-2020, 01:06 PM
Last Post: zen89
  NPIX-4DI4DO and NetPi-Nodered container issues alhammi 4 2,481 November-16th-2020, 01:35 PM
Last Post: alhammi

Forum Jump:

Users browsing this thread: 1 Guest(s)