Skip to content

Instantly share code, notes, and snippets.

@mrhillsman
Last active December 15, 2017 14:59
Show Gist options
  • Save mrhillsman/397583a5e831091db99bc8fbccee7307 to your computer and use it in GitHub Desktop.
Save mrhillsman/397583a5e831091db99bc8fbccee7307 to your computer and use it in GitHub Desktop.
Install Docker CE on Ubuntu
#!/bin/bash
# Check what version of Ubuntu we have installed
source /etc/lsb-release
# Environment variables made available
# DISTRIB_ID=Ubuntu
# DISTRIB_RELEASE=14.04
# DISTRIB_CODENAME=trusty
# DISTRIB_DESCRIPTION="Ubuntu 14.04.2 LTS"
MAJ_RELEASE=`echo ${DISTRIB_RELEASE}|cut -d'.' -f1`
if [ ${MAJ_RELEASE} -lt 14 ]; then
echo "Unfortunately at least Ubuntu 14.04 is required"
exit 1
fi
# Remove previous versions
apt-get remove -y docker docker-engine docker.io
# Install dependencies
## If Ubuntu 14.04 we want to add support for AUFS
if [ "${MAJ_RELEASE}" -eq 14 ]; then
apt-get update
apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
fi
## Setup Docker CE repository
apt-get update
apt-get install -y apt-transport-https \
ca-certificates \
curl \
software-properties-common
## Add official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# Install Docker CE
apt-get update
apt-get install -y docker-ce
# Verify installation via 'hello-world' container
docker run hello-world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment