Skip to content

Instantly share code, notes, and snippets.

@NamesMT
Created September 15, 2024 16:57
Show Gist options
  • Save NamesMT/0708cc223a3db878df0477159115a49b to your computer and use it in GitHub Desktop.
Save NamesMT/0708cc223a3db878df0477159115a49b to your computer and use it in GitHub Desktop.
Custom docker service start stop script
BASE=docker
DOCKERD=/usr/bin/dockerd
# This is the pid file managed by docker itself
DOCKER_PIDFILE=/var/run/$BASE.pid
# This is the pid file created/managed by start-stop-daemon
DOCKER_SSD_PIDFILE=/var/run/$BASE-ssd.pid
DOCKER_LOGFILE=/var/log/$BASE.log
DOCKER_OPTS=
DOCKER_DESC="Docker"
if [ "$1" = "stop" ]; then
echo "stopping docker..."
sudo start-stop-daemon --stop --pidfile "$DOCKER_SSD_PIDFILE"
elif ! pgrep "dockerd" >/dev/null; then
echo "starting docker..."
sudo start-stop-daemon --start --background \
--exec "$DOCKERD" \
--pidfile "$DOCKER_SSD_PIDFILE" \
--make-pidfile \
-- \
-p "$DOCKER_PIDFILE" \
$DOCKER_OPTS
#>> "$DOCKER_LOGFILE" 2>&1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment