0

Every time when I start a Docker container my RPi device loses it wireless board configuration. By configuration I mean that it loses its IP address, the DNS resolver and the gateway settings.

Because of that I can't connect to device on net, has anyone had a similar issue before?

# Before Docker container starts
wlan0     Link encap:Ethernet  HWaddr b8:27:eb:a8:93:73  
          inet addr:192.168.0.20  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::ada4:3dc4:b933:7a5b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:525 errors:0 dropped:19 overruns:0 frame:0
          TX packets:411 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:558627 (545.5 KiB)  TX bytes:48299 (47.1 KiB)
# After Docker container starts
wlan0     Link encap:Ethernet  HWaddr b8:27:eb:a8:93:73  
          inet6 addr: fe80::ada4:3dc4:b933:7a5b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5830 errors:0 dropped:19 overruns:0 frame:0
          TX packets:4087 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5743386 (5.4 MiB)  TX bytes:566484 (553.2 KiB)

Some notes:

  • This happens with any container, not a specific one;
  • To stop the issue I just need to stop all containers that are running.
2
  • 1
    @techraf I have added more info, hope it helps, please tell me if I should add something else. Dec 12, 2016 at 0:19
  • i am having the same issue but i do know what is the solution. I stopped all the containers but this is did not solve the problem. still i wifi (wlan0) is not recognized in the stretch OS.
    – Mostafa
    Apr 12, 2018 at 15:56

3 Answers 3

2

I am facing the same issue, the Wi-Fi gets disconnected after starting one docker container.

The issue has been temporarily resolved by disabling the static IP.

  1. Check the file - /etc/dhcpcd.conf, make sure all the static IP mapped with wlan0/SSIDs are commented out.

  2. Reboot the Raspberry Pi.

  3. Start the container.

Hope it works for you too.

2
  • It's been a long time that I had this problem. I solved it by a workaround. I'll accept this as the answer, so, if someone else encounter the same problem, maybe it will help him. Jul 12, 2018 at 12:59
  • I had the same issue. When I started any container, wifi just disappeared in rasbian. By removing the static ip from the dhcpcd.conf fixed the issue. Feb 15, 2020 at 9:19
4

I have the same issue, and did not really understood the root cause but found a solution. It looks like DHCPC service failed to load once docker is running/started

You can check by running this, if Wireless is back to life it's likely the same issue I had

sudo systemctl restart dhcpcd    

The clean fixed I did, was to edit the dhcpcd.service and adding a docker dependencies to wait for docker.service to run before dhcpcd service

it looks like

sudo nano /lib/systemd/system/dhcpcd.service

then change the [Unit] block as below (by dropping the Before=network.target

[Unit]
Description=dhcpcd on all interfaces
Wants=network.target docker.service
After=docker.service
1
  • This answer safes me a lot of time. Problem occurs for me, after I running a docker-compose stack on my RPI 3B+. After a reboot my wpa-controller was not able to establish a connection. After=docker.service solve that problem.
    – Mar Tin
    Mar 28, 2021 at 14:51
1

Your problem cannot be reproduced given the information you provided and here's a minimal, working procedure to prove:

  • start with a fresh Raspbian image on your Raspberry Pi 3

  • login

  • configure Wi-Fi interface (/etc/wpa_supplicant/wpa_supplicant.conf)

    and connect to the network (assuming you get 192.168.0.20 from DHCP)

  • install Docker:

      sudo curl -sSL https://get.docker.com | sh
    
  • run container:

      sudo docker run -d -p 8080:80 lalyos/rpi-nginx
    
  • check the connectivity (on wlan0 interface) from another machine:

      curl 192.168.0.20:8080
    

It works, you should get a short HTML document response containing:

<h1>Welcome to nginx!</h1>

It means wlan0 also works.

1
  • Well, this has started after I have fixed the IP address for the wifi board through the gui tool in Raspbian. If I connect the RPI through a cable connection, this issue don't happens at all. Dec 12, 2016 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.