Diagnosis
Time the stop:
time docker stop my-container
10 seconds confirms the symptom.
Inspect the entrypoint:
docker inspect my-container --format '{{.Path}}'
docker inspect my-container --format '{{json .Config.Cmd}}'
A shell (/bin/sh) or a script that doesn’t exec is the most
common cause.
Fix
docker run --init --name my-container -d myorg/app:1.0.0
Or rebuild the image with tini baked in:
COPY --from=ghcr.io/krallin/tini:latest /usr/local/bin/tini /sbin/tini
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["python3", "/app/server.py"]
Verify
time docker stop my-container
# real 0m0.532s