Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Wrap an app in docker container and catch the signals from docker using xonsh shell.

License

Notifications You must be signed in to change notification settings

anki-code/docker-xonsh-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-xonsh-wrapper shows the way to wrap an app (e.g. server) in docker container using xonsh shell to:

  • catching the signals from docker (SIGTERM, SIGINT, SIGHUP)
  • doing work before starting the app
  • doing work after stopping the app

To 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

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

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

About

Wrap an app in docker container and catch the signals from docker using xonsh shell.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published