Skip to content

Instantly share code, notes, and snippets.

@danbeaulieu
Created February 21, 2014 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danbeaulieu/a4f4196188ac81189260 to your computer and use it in GitHub Desktop.
Save danbeaulieu/a4f4196188ac81189260 to your computer and use it in GitHub Desktop.
## Inside /etc/init.d
#!/bin/sh
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11"
start() {
if [ "${USE_DOCKER}" ]; then
start my_service
else
/opt/scripts/start.sh
fi
}
stop() {
}
case "$1" in
start)
echo -n "Starting: "
start
;;
stop)
echo -n "Stopping: "
stop
;;
****)
echo "Usage: /etc/init.d/$NAME {start|stop}"
exit 1
;;
esac
exit 0
## Inside /etc/init
description "Docker container"
author "Me"
stop on runlevel [!2345]
respawn
script
# Wait for docker to finish starting up first.
FILE=/var/run/docker.sock
while [ ! -e $FILE ] ; do
inotifywait -t 2 -e create $(dirname $FILE)
done
/usr/bin/docker run -i -t -rm ubuntu bash
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment