{"id":27442396,"url":"https://github.com/drpsychick/docker-signal-demo","last_synced_at":"2026-04-14T06:33:18.008Z","repository":{"id":58004114,"uuid":"297774142","full_name":"DrPsychick/docker-signal-demo","owner":"DrPsychick","description":"Demonstrate signal handling in a Docker container including tmux and screen.","archived":false,"fork":false,"pushed_at":"2022-08-27T13:54:29.000Z","size":10,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-19T01:00:32.876Z","etag":null,"topics":["bash","docker","screen","signal","signal-handling","tmux"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DrPsychick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-22T21:16:13.000Z","updated_at":"2023-03-04T00:40:11.000Z","dependencies_parsed_at":"2022-09-02T12:51:05.741Z","dependency_job_id":null,"html_url":"https://github.com/DrPsychick/docker-signal-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DrPsychick/docker-signal-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DrPsychick%2Fdocker-signal-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DrPsychick%2Fdocker-signal-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DrPsychick%2Fdocker-signal-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DrPsychick%2Fdocker-signal-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DrPsychick","download_url":"https://codeload.github.com/DrPsychick/docker-signal-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DrPsychick%2Fdocker-signal-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31785677,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","docker","screen","signal","signal-handling","tmux"],"created_at":"2025-04-15T00:27:27.396Z","updated_at":"2026-04-14T06:33:17.993Z","avatar_url":"https://github.com/DrPsychick.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Docker image: signal-demo](https://hub.docker.com/r/drpsychick/signal-demo/)\nHandling signals in a docker container\n\n[![Docker image](https://img.shields.io/docker/image-size/drpsychick/signal-demo?sort=date)](https://hub.docker.com/r/drpsychick/signal-demo/tags)\n[![Travis build status](https://travis-ci.com/DrPsychick/docker-signal-demo.svg?branch=master)](https://travis-ci.com/DrPsychick/docker-signal-demo)\n[![DockerHub pulls](https://img.shields.io/docker/pulls/drpsychick/signal-demo.svg)](https://hub.docker.com/r/drpsychick/signal-demo/)\n[![DockerHub stars](https://img.shields.io/docker/stars/drpsychick/signal-demo.svg)](https://hub.docker.com/r/drpsychick/signal-demo/)\n[![GitHub stars](https://img.shields.io/github/stars/drpsychick/docker-signal-demo.svg)](https://github.com/drpsychick/docker-signal-demo)\n\n## Purpose\nDemo/playground to play with signal handling in docker / kubernetes, additionally along with `tmux` or `screen` sessions.\nSome apps **require a terminal**, so it's easiest to run them in a `tmux`/`screen` session.\n\nIMHO `tmux` is a bit easier to automate while I used `screen` a lot \"interactively\" (quite a while ago). \n\n## Try it\n### Docker\n```shell script\ndocker run -it --rm --name demo drpsychick/signal-demo\n# will run and wait for signal\n\n\u003e docker stop demo # in another shell\n--\u003e got TERM signal\n```\n\n### Kubernetes\n```shell script\nkubectl apply -f k8s/signal-demo.yml\nkubectl logs -f -l app=signal-demo\n# will run and wait for signal\n\n\u003e kubectl delete pod -l app=signal-demo # in another shell (k8s will create a new pod)\n--\u003e got TERM signal\n\n\u003e kubectl delete -f k8s/signal-demo.yml # in another shell\n--\u003e got TERM signal\n```\n\n## Sending signals\nIn interactive mode, the first signal to try is Ctrl-C, it will send an INT signal.\n\nOther signals can be sent through the `exec` commands to PID 1 in the pod:\n```shell script\ndocker exec test kill -HUP 1\nkubectl exec deploy/signal-demo-deployment -- kill -USR1 1\n```\n\nYou'll see the corresponding messages as defined in the trap commands:\n```shell script\ntrap 'echo \"--\u003e got signal: TERM - shutdown.\"; tmux kill-server; screen -X kill' TERM\ntrap 'echo \"--\u003e got signal: INT - shutting down...\"; tmux send-keys C-c exit C-m; screen -X kill' INT\ntrap 'echo \"--\u003e got signal: USR1 - stopping tmux\"; tmux send-keys C-c exit C-m' USR1\ntrap 'echo \"--\u003e got signal: USR2 - stopping screen\"; screen -X kill' USR2\ntrap 'echo \"--\u003e got signal: HUP - status report\"; ps faxuwww' HUP\ntrap 'echo \"--\u003e got signal: QUIT/ABRT\"' QUIT ABRT\n```\n\n## What happens when you use `exec`\n```shell script\ndocker run --rm --name demo -e EXEC_DEMO=yes drpsychick/signal-demo\n```\nWhen you `exec \u003ccmd\u003e` then it takes over the running process and the shell script stops at that point. The command executed will be PID #1.\n\nThis can be very useful if you have an app that takes over signal handling and cleanup of children as well.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrpsychick%2Fdocker-signal-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrpsychick%2Fdocker-signal-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrpsychick%2Fdocker-signal-demo/lists"}