Skip to content

Instantly share code, notes, and snippets.

@shelan
Last active March 9, 2016 15:22
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 shelan/815fe2e10dda8864be8c to your computer and use it in GitHub Desktop.
Save shelan/815fe2e10dda8864be8c to your computer and use it in GitHub Desktop.
#!/bin/bash
# ---------------------------------------------------------------------------
# docker-install.sh - Install Docker
# Copyright 2016, <shelan@Shelans-MacBook-Pro.local>
# All rights reserved.
# Usage: docker-install.sh [-h|--help]
# Revision history:
# 2016-03-09 Created by script-generator.sh ver. 3.3
# ---------------------------------------------------------------------------
PROGNAME=${0##*/}
VERSION="0.1"
clean_up() { # Perform pre-exit housekeeping
return
}
error_exit() {
echo -e "${PROGNAME}: ${1:-"Unknown Error"}" >&2
clean_up
exit 1
}
graceful_exit() {
clean_up
exit
}
signal_exit() { # Handle trapped signals
case $1 in
INT)
error_exit "Program interrupted by user" ;;
TERM)
echo -e "\n$PROGNAME: Program terminated" >&2
graceful_exit ;;
*)
error_exit "$PROGNAME: Terminating on unknown signal" ;;
esac
}
usage() {
echo -e "Usage: $PROGNAME [-h|--help]"
}
help_message() {
cat <<- _EOF_
$PROGNAME ver. $VERSION
Install Docker
$(usage)
Options:
-h, --help Display this help message and exit.
NOTE: You must be the superuser to run this script.
_EOF_
return
}
# Trap signals
trap "signal_exit TERM" TERM HUP
trap "signal_exit INT" INT
# Check for root UID
if [[ $(id -u) != 0 ]]; then
error_exit "You must be the superuser to run this script."
fi
# Parse command-line
while [[ -n $1 ]]; do
case $1 in
-h | --help)
help_message; graceful_exit ;;
-* | --*)
usage
error_exit "Unknown option $1" ;;
*)
echo "Argument $1 to process..." ;;
esac
shift
done
# Main logic
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo sh -c 'echo "deb https://apt.dockerproject.org/repo ubuntu-wily main" > /etc/apt/sources.list.d/docker.list'
sudo apt-get update
sudo apt-get -y install linux-image-extra-$(uname -r)
sudo apt-get -y install docker-engine
usermod -a -G docker $USER ## add vagrant user to docker group
sudo mkdir -p /etc/systemd/system/docker.service.d/
wget
sudo echo "[Service]" >> /etc/systemd/system/docker.service.d/docker.conf
sudo echo "ExecStart=" >> /etc/systemd/system/docker.service.d/docker.conf
sudo echo "ExecStart=/usr/bin/docker daemon -H fd:// --cluster-store=consul://172.28.128.5:8500 --cluster-advertise=eth1:2375 -H=tcp://0.0.0.0:2375 -H=unix:///var/run/docker.sock" >> /etc/systemd/system/docker.service.d/docker.conf
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl status docker
graceful_exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment