https://pantsbuild.org/ logo
#general
Title
# general
h

happy-family-315

06/23/2022, 12:58 PM
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

curved-television-6568

06/23/2022, 1:00 PM
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

happy-family-315

06/23/2022, 1:02 PM
Hi, thanks for the answer. Is there a workaround or anything else I can do to solve this?
c

curved-television-6568

06/23/2022, 1:04 PM
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

witty-crayon-22786

06/23/2022, 3:57 PM
which version of pants is this? more recent versions tear down more gracefully
3 Views