Skip to content

Instantly share code, notes, and snippets.

@christianberg
Last active April 1, 2016 12:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save christianberg/6082234 to your computer and use it in GitHub Desktop.
Save christianberg/6082234 to your computer and use it in GitHub Desktop.
Script to install Docker on a Ubuntu 13.04 host
#/bin/bash
set -e
echo "=== Activating Firewall (only SSH allowed) ==="
ufw allow ssh
ufw --force enable
if [ ! -f /swapfile ]; then
echo "=== Activating swap ==="
fallocate -l 1G /swapfile
mkswap /swapfile
swapon /swapfile
chmod 0600 /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
fi
echo "=== Installing Kernel with LXC and AUFS Support ==="
export DEBIAN_FRONTEND=noninteractive
apt-get -qq update
apt-get install -qqy linux-image-extra-`uname -r`
echo "=== Installing Docker and git ==="
curl http://get.docker.io/gpg | apt-key add -
echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
apt-get -qq update
apt-get install -qqy lxc-docker git
echo "=== Opening Firewall for Docker Network ==="
sed -i.bak 's/DEFAULT_FORWARD_POLICY=".*"/DEFAULT_FORWARD_POLICY="ACCEPT"/' /etc/default/ufw
sed -r -i.bak 's/^#(net\/ipv4\/ip_forward=1|net\/ipv6\/conf\/default\/forwarding=1|net\/ipv6\/conf\/all\/forwarding=1)$/\1/' /etc/ufw/sysctl.conf
ufw disable
ufw --force enable
ufw allow out on docker0
ufw allow in on docker0
echo "=== Verifying Installation ==="
docker run busybox /bin/echo '*** It works! ***'
@cggaurav
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment