Summary
Commit e2c6309 ("Improvments to Docker Compose and cleanup of env variables") removed the top-level import docker from src/tasks.py and reworked _docker_host_ip() to use a plain socket instead of the Docker SDK. However, _container_exposed_port() still calls the SDK:
client = docker.from_env(version="1.24")
With no import docker in the module, that line raises:
NameError: name 'docker' is not defined
How to reproduce / effect
_container_exposed_port() is reached from _geonode_public_port() → update() on container start whenever GEONODE_LB_PORT is unset. The NameError is swallowed by the function's own try/except, which prints a traceback and falls back to the hardcoded "80". So on affected startups:
- the Docker-API port detection never works (always returns
80), and
- a traceback is printed in the entrypoint logs every time.
A quick confirmation that the name is undefined in the current module:
import ast
tree = ast.parse(open("src/tasks.py").read())
# no Import/ImportFrom node binds the name "docker", yet "docker.from_env(" is present
Possible fixes
- Minimal — re-add
import docker (restores the previous behavior).
- Consistent with the cleanup — drop the Docker-SDK branch in
_container_exposed_port() the way _docker_host_ip() was already moved off the SDK, and detect the port another way (or rely on GEONODE_LB_PORT).
Happy to open a PR for whichever direction you prefer.
Summary
Commit e2c6309 ("Improvments to Docker Compose and cleanup of env variables") removed the top-level
import dockerfromsrc/tasks.pyand reworked_docker_host_ip()to use a plain socket instead of the Docker SDK. However,_container_exposed_port()still calls the SDK:With no
import dockerin the module, that line raises:How to reproduce / effect
_container_exposed_port()is reached from_geonode_public_port()→update()on container start wheneverGEONODE_LB_PORTis unset. TheNameErroris swallowed by the function's owntry/except, which prints a traceback and falls back to the hardcoded"80". So on affected startups:80), andA quick confirmation that the name is undefined in the current module:
Possible fixes
import docker(restores the previous behavior)._container_exposed_port()the way_docker_host_ip()was already moved off the SDK, and detect the port another way (or rely onGEONODE_LB_PORT).Happy to open a PR for whichever direction you prefer.