docs icon indicating copy to clipboard operation
docs copied to clipboard

Example of exec form of ENTRYPOINT using trap signals doesn't appear to work

Open tylerFowler opened this issue 1 year ago • 1 comments
trafficstars

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.

tylerFowler avatar Apr 03 '24 20:04 tylerFowler

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

docker-robot[bot] avatar Jul 02 '24 01:07 docker-robot[bot]

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

docker-robot[bot] avatar Aug 15 '24 03:08 docker-robot[bot]