Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tini as PID 1 process in front of entrypoint #24

Merged
merged 1 commit into from
Apr 12, 2024
Merged

Add tini as PID 1 process in front of entrypoint #24

merged 1 commit into from
Apr 12, 2024

Conversation

lreiher
Copy link
Member

@lreiher lreiher commented Apr 11, 2024

Problem

  • containers take long to shut down
  • reason is that docker stop sends SIGTERM signal
  • ROS listens for SIGINT
  • after 10s, container is killed via SIGKILL

Solution

  • use tini as init process: Why tini?
  • Why Your Dockerized Application Isn’t Receiving Signals
  • correctly forwards signals and speeds up container shutdown
  • alternatives
    • stop_signal: SIGINT in Docker Compose: works for speeding up shutdown of ROS apps, but doesn't bring tini benefits
    • docker run --init: automatically starts containers with tini; works for speeding up shutdown, but is easily forgotten

Shutdown Evaluation

services:

  current:
    image: ghcr.io/ika-rwth-aachen/mqtt_client:ros2

  stop-signal:
    image: ghcr.io/ika-rwth-aachen/mqtt_client:ros2
    stop_signal: SIGINT

  tini-by-docker:
    image: ghcr.io/ika-rwth-aachen/mqtt_client:ros2
    init: true

  tini:
    image: mqtt_client # image built by this version of docker-ros
time docker stop $(basename $(pwd))-current-1
tmp-current-1
docker stop $(basename $(pwd))-current-1  0,05s user 0,04s system 0% cpu 10,316 total
time docker stop $(basename $(pwd))-stop-signal-1
tmp-stop-signal-1
docker stop $(basename $(pwd))-stop-signal-1  0,05s user 0,04s system 13% cpu 0,624 total
time docker stop $(basename $(pwd))-tini-by-docker-1
tmp-tini-by-docker-1
docker stop $(basename $(pwd))-tini-by-docker-1 0,05s user 0,04s system 27% cpu 0,310 total
time docker stop $(basename $(pwd))-tini-1
tmp-tini-1
docker stop $(basename $(pwd))-tini-1  0,05s user 0,03s system 31% cpu 0,262 total

speeds up container shutdown, correctly forwards signals
@lreiher lreiher requested a review from jpbusch April 11, 2024 20:59
@lreiher
Copy link
Member Author

lreiher commented Apr 11, 2024

@TillBeemelmanns

@lreiher lreiher merged commit c925799 into main Apr 12, 2024
12 checks passed
@lreiher lreiher deleted the tini branch April 12, 2024 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants