Hi I'm having trouble running a restartable docker...
# general
b
Hi I'm having trouble running a restartable docker. It seems that a docker target ran with
restartable=True
doesn't wait until the previous docker container stops. I'll provide an example: src/docker/BUILD
Copy code
docker_image(
    name="app",
    dependencies=["src/python/app:bin"],
    restartable=True
)
src/python/app/BUILD
Copy code
python_sources()
pex_binary(
    name="bin",
    entry_point="main.py"
)
src/docker/Dockerfile
Copy code
FROM python:3.9-slim

COPY <http://src.python.app/bin.pex|src.python.app/bin.pex> /app/bin

ENTRYPOINT [ "/app/bin" ]
Then running as:
./pants run --docker-run-args="-p 8000:8000" src/docker:app
Runs fine, but fails when any file is modified:
docker: Error response from daemon: driver failed programming external connectivity on endpoint cool_gould (5a6265badca64afa4e304e6475119f912621ee8cddf8e195d36a6d0d55b7854f): Bind for 0.0.0.0:8000 failed: port is already allocated.
./pants run --docker-run-args="-p 8000:8000 --name=app" src/docker:app
Also runs fine, but fails when any file is modified:
docker: Error response from daemon: Conflict. The container name "/app" is already in use by container "e003d8f7b8c1e963e1f540ab49a06b67a21530938ac1f9092862e858e800dcfe". You have to remove (or rename) that container to be able to reuse that name.
passing --rm to the --docker-run-args gives the same result