Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker stuck if no network at boot #278

Open
cyrilpawelko opened this issue Dec 23, 2024 · 0 comments
Open

Docker stuck if no network at boot #278

cyrilpawelko opened this issue Dec 23, 2024 · 0 comments

Comments

@cyrilpawelko
Copy link

Describe the bug
I'm running the docker gateway on my Raspi running Librelec. It's perfect for not messing with LibreElec.
Sinon docker-compose is not available on LibreElec, I start the container with the --restart always option :
docker run --restart always --network host -e MQTT_HOST=nas.pawelko.local -e BLE=true -e DISCOVERY=true -e SCANNING_MODE=active -e PUBLISH_ALL=false -e SCAN_TIME=1 -e TIME_BETWEEN=20 -v /var/run/dbus:/var/run/dbus --name TheengsGateway theengs/gateway
On reboot, the container is started, but get stucks because network is not ready :

INFO:BLEGateway:Starting BLE scan
ERROR:BLEGateway:Connection error
Traceback (most recent call last):
  File "/opt/venv/lib/python3.11/site-packages/TheengsGateway/ble_gateway.py", line 193, in connect_mqtt
    self.client.connect(
  File "/opt/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1429, in connect
    return self.reconnect()
           ^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1592, in reconnect
    self._sock = self._create_socket()
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 4598, in _create_socket
    sock = self._create_socket_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 4623, in _create_socket_connection
    return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/socket.py", line 827, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/socket.py", line 962, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno -3] Temporary failure in name resolution

After a container restart, it works perfectly.

To Reproduce
Installer docker image
Run it with docker --restart always
Reboot
Check docker logs

Expected behavior
Should either completely fail or retry MQTT host name resolution until success.

Note
Since the failure is in name resolution, using the MQTT server IP address is a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant