Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anki-code/docker-xonsh-wrapper
Wrap an app in docker container and catch the signals from docker using xonsh shell.
https://github.com/anki-code/docker-xonsh-wrapper
docker xonsh xonsh-dev xontrib
Last synced: 28 days ago
JSON representation
Wrap an app in docker container and catch the signals from docker using xonsh shell.
- Host: GitHub
- URL: https://github.com/anki-code/docker-xonsh-wrapper
- Owner: anki-code
- License: bsd-3-clause
- Created: 2020-09-29T11:01:12.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-21T14:11:37.000Z (almost 2 years ago)
- Last Synced: 2024-08-03T01:15:45.163Z (3 months ago)
- Topics: docker, xonsh, xonsh-dev, xontrib
- Language: Python
- Homepage:
- Size: 25.4 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
**docker-xonsh-wrapper** shows the way to wrap an app (e.g. server) in docker container using [xonsh shell](https://xon.sh/contents.html) to:
* catching the signals from docker (SIGTERM, SIGINT, SIGHUP)
* doing work before starting the app
* doing work after stopping the appTo achieve this install xonsh in the container and use `run.xsh` as an entrypoint.
If you like the idea of xxh click ⭐ on the repo and stay tuned.
## Build and run the demo container
```shell script
git clone https://github.com/anki-code/docker-xonsh-wrapper
cd xonsh-docker-wrapper
docker build . -t local/docker-xonsh-wrapper
docker run --rm -it local/docker-xonsh-wrapper
```## Example
```shell script
docker run --rm -it local/docker-xonsh-wrapper
# [Work before running the app]
# The app just sleep 2 minutes zZzZzZz...
#
# # Run docker stop, docker restart or press Ctrl+C
#
# CATCH: signum=15, stopping the process...
#
# # After getting closing signal the app could take time
# # to stopping (closing the database, clean the memory)
# # and we're waiting the ending before doing final work.
#
# [Work after running the app or getting stop signals]
```## Related links
* Real life example - [metabase-sql-wrapper](https://github.com/anki-code/metabase-sql-wrapper)
* [Trapping signal from “docker stop” in bash](https://stackoverflow.com/questions/20602675/trapping-signal-from-docker-stop-in-bash/20606897#20606897)