FreeTAKTeam / FreeTAKServer-Docker

Official Docker Image for FreeTAKServer
Eclipse Public License 2.0
42 stars 26 forks source link

Detect IP address assigned to container #31

Closed hickey closed 1 year ago

hickey commented 1 year ago

If one follows the instructions contained in the README.md, the UI in the container fails with the following message:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/run.py", line 61, in <module>
    wsgi.server(sock = eventlet.listen((app_config.APPIP, app_config.APPPort)), site=app)
  File "/usr/local/lib/python3.8/dist-packages/eventlet/convenience.py", line 78, in listen
    sock.bind(addr)
OSError: [Errno 99] Cannot assign requested address

This is primarily due to the fact that the IP specified on the Docker command line is not assigned to the container unless --network host is used to override the default bridge network. Using the bridge network, it is not possible to know the IP address ahead of time to include it on the command line.

This patch will allow the startup script to determine what IP was assigned to the container and then use that when starting up the UI. In addition, the previous behavior of specify the IP to bind to is preserved for backward compatibility (although I can not find a reason that it would need to be used given this patch).

This patch would also be necessary when the container is fronted by a reverse proxy such at Traefik.