docs
docs copied to clipboard
Example of exec form of ENTRYPOINT using trap signals doesn't appear to work
Is this a docs issue?
- [X] My issue is about the documentation content or website
Type of issue
Information is incorrect
Description
The docs for the exec form of ENTRYPOINT, specifically the fourth example illustrating how to use trap to manage background processes in an entrypoint script do not appear to work.
I have tried this approach myself with a very simple entrypoint script (which also uses the ubuntu base image):
#!/bin/sh
trap "echo Trapped" INT TERM
echo "Faking startup"
tail -F ./logfile
echo "Tail exited, faking some cleanup"
echo "Exited $0"
And using a bare docker run, this entrypoint script does not respond to INT or TERM signals at all, even when using docker exec -it ... "kill -INT 1". In my attempts docker stop will not trigger the trap and it must fallback to the SIGKILL signal which of course does work. I have verified that this entrypoint script is indeed PID 1.
Initially I thought perhaps --init would need to be added to make this work, but I receive the same non-functioning result. The only way I have been able to trigger the trap at all is to use docker run -it ... and then manually give a SIGINT via ctrl+c keyboard interrupt, but of course this isn't usable for production scenarios.
Location
https://docs.docker.com/reference/dockerfile/#exec-form-entrypoint-example
Suggestion
Frankly it's not clear to my why this doesn't work so perhaps more details are required, or some change along the way prevents this strategy from functioning.
There hasn't been any activity on this issue for a long time.
If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment.
If not, this issue will be closed in 14 days. This helps our maintainers focus on the active issues.
Prevent issues from auto-closing with a /lifecycle frozen comment.
/lifecycle stale
Closed issues are locked after 30 days of inactivity. This helps our team focus on active issues.
If you have found a problem that seems similar to this, please open a new issue.
/lifecycle locked