Created
March 10, 2017 17:24
-
-
Save snodnipper/564e80b885d7bae51edbbec97f773b05 to your computer and use it in GitHub Desktop.
InstallDocker.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#====================================================================== | |
# Prepare Docker Installation | |
# https://docs.docker.com/engine/installation/linux/ubuntulinux/#/install-the-latest-version | |
#====================================================================== | |
if [ $EUID != 0 ]; then | |
sudo "$0" "$@" | |
exit $? | |
fi | |
function dockerPrepare { | |
UBUNTU_RELEASE=$(lsb_release -rs) | |
if [ "$UBUNTU_RELEASE" != "12.04" ] && | |
[ "$UBUNTU_RELEASE" != "14.04" ] && | |
[ "$UBUNTU_RELEASE" != "15.10" ] && | |
[ "$UBUNTU_RELEASE" != "16.04" ]; then | |
echo "THIS SCRIPT DOES NOT SUPPORT YOUR OS VERSION." | |
echo " - latest supported version is Ubuntu 16.04" | |
exit | |
fi | |
sudo apt-get -y update | |
sudo apt-get -y install apt-transport-https ca-certificates | |
sudo apt-key adv \ | |
--keyserver hkp://ha.pool.sks-keyservers.net:80 \ | |
--recv-keys 58118E89F3A912897C070ADBF76221572C52609D | |
DOCKER_REPO="UNSUPPORTED" | |
if [ "$UBUNTU_RELEASE" == "16.04" ]; then | |
DOCKER_REPO="deb https://apt.dockerproject.org/repo ubuntu-xenial main" | |
elif [ "$UBUNTU_RELEASE" == "15.10" ]; then | |
DOCKER_REPO="deb https://apt.dockerproject.org/repo ubuntu-wily main" | |
elif [ "$UBUNTU_RELEASE" == "14.04" ]; then | |
DOCKER_REPO="deb https://apt.dockerproject.org/repo ubuntu-trusty main" | |
elif [ "$UBUNTU_RELEASE" == "12.04" ]; then | |
DOCKER_REPO="deb https://apt.dockerproject.org/repo ubuntu-precise main" | |
else | |
echo "UNSUPPORTED." | |
exit | |
fi | |
echo "$DOCKER_REPO" | sudo tee /etc/apt/sources.list.d/docker.list | |
sudo apt-get -y update | |
apt-cache policy docker-engine | |
if [ "$UBUNTU_RELEASE" != "14.04" ] && | |
[ "$UBUNTU_RELEASE" != "15.10" ] && | |
[ "$UBUNTU_RELEASE" != "16.04" ]; then | |
sudo apt-get -y update | |
sudo apt-get -y install linux-image-extra-"$(uname -r)" linux-image-extra-virtual | |
elif [ "$UBUNTU_RELEASE" == "12.04" ]; then | |
sudo apt-get -y update | |
sudo apt-get -y install linux-image-generic-lts-trusty | |
if [ ! -f rebooted_for_precise ]; then | |
touch rebooted_for_precise | |
sudo reboot | |
fi | |
fi | |
} | |
#====================================================================== | |
# Install latest version of Docker | |
# Note: for production versions a specific version should be used | |
#====================================================================== | |
function dockerInstall() { | |
sudo apt-get -y update | |
sudo apt-get -y install docker-engine | |
sudo service docker start | |
sudo docker run hello-world | |
} | |
#====================================================================== | |
# main | |
#====================================================================== | |
if [ $EUID != 0 ]; then | |
sudo "$0" "$@" | |
exit $? | |
fi | |
dockerPrepare | |
dockerInstall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment