Hi, I am trying to run a django pex binary inside ...
# general
h
Hi, I am trying to run a django pex binary inside a docker container using
./pants run --docker-run-args="-p 9999:9999" django:dev_image -- runserver 0.0.0.0:9999 --noreload
but hot code reloading throws an error:
docker: Error response from daemon: driver failed programming external connectivity on endpoint [...] Bind for 0.0.0.0:9999 failed: port is already allocated.
pex and docker target both are using the restartable=True option.
c
Hi, It could be that pants is restarting the new process too soon, so that Docker hasn’t had enough time cleaning up the previous container.
h
Hi, thanks for the answer. Is there a workaround or anything else I can do to solve this?
c
I don’t know of any good workarounds. The first that comes to mind is to not bind to a fixed port on the host, and then look up the containers port for each iteration, but I can see that becoming a real bottleneck of impracticability.. so, not one I can think of right now, really. Sorry.
@witty-crayon-22786 perhaps add a “restart delay” option? but that could be rather arbitrary I guess, how long is long enough.. etc.
w
which version of pants is this? more recent versions tear down more gracefully