OTBR Docker - Why doesn't entrypoint configuration work?

Problem

I’m trying to configure OTBR in docker-compose via entrypoint to make it automatically bind to 0.0.0.0 instead of 127.0.0.1.

docker-compose.yml attempt:

entrypoint: ["/bin/bash", "-c", "sed -i 's/-a 127.0.0.1/-a 0.0.0.0/g' /etc/default/otbr-web; sed -i 's/127.0.0.1/0.0.0.0/g' /etc/default/otbr-agent; exec /app/etc/docker/border-router/setup-host --radio-url 'spinel+hdlc+uart:///dev/serial/by-id/...'"]

Result:

  • sed: can't read /etc/default/otbr-web: No such file or directory
  • setup-host loops indefinitely
  • container keeps restarting

Questions

  1. Doesn’t /etc/default/otbr-web exist when entrypoint runs?

    • Is the file created later in the startup process?
  2. Is setup-host the wrong entrypoint?

    • Should I use a different startup script?
  3. Is there a better way?

    • Dockerfile RUN? Init script? Environment variable?

Current Workaround (works perfectly)

docker exec otbr sed -i 's/-a 127.0.0.1/-a 0.0.0.0/g' /etc/default/otbr-web
docker exec otbr service otbr-web restart

But this isn’t elegant. How do others handle this?

Does anyone have a working docker-compose setup with external port binding for OTBR?

Environment

  • openthread/otbr:latest
  • DietPi
  • ConBee II
  • network_mode: host

Here’s my docker-compose file;

  otbr:
    image: openthread/border-router:latest
    container_name: otbr
    restart: unless-stopped
    network_mode: host
    privileged: true
    devices:
      - /dev/serial/by-id/usb-SONOFF_SONOFF_Dongle_Plus_MG24_2690c8b8bdf5ef11841b96a29ed47d52-if00-port0:/dev/ttyUSB3
      - /dev/net/tun:/dev/net/tun
    volumes:
      - /home/pi/docker/otbr/data:/data
    environment:
      OT_RCP_DEVICE: "spinel+hdlc+uart:///dev/ttyUSB3?uart-baudrate=460800"
      OT_INFRA_IF: "eth0"
      OT_THREAD_IF: "wpan0"
      OT_LOG_LEVEL: "7"
      OT_WEB_LISTEN_ADDR: "0.0.0.0"
      OT_REST_LISTEN_ADDR: "0.0.0.0"

A lot of older docu suggested you use OTBR_WEB_LISTEN or similar, but my container seems to work fine. Or well, it’s at least reachable on the ports and interfaces I want. I still haven’t managed to get the whole matter/thread malarkey working due to … networking issues? (even though everything is reachable from any device that should matter, it always ends up stalling at the last hurdle of actually commissioning a device to the OTBR server network and I’ve got no hair left to pull so).

You posted this exact question to another thread (not recommended). See my answer there.

Short answer: it depends on what docker image you’re using, but you did not specify yours.