Skip to content

Instantly share code, notes, and snippets.

@pascalandy
Forked from alexellis/install-docker-master.sh
Created October 28, 2016 17:20
Show Gist options
  • Save pascalandy/6bd6e60a9ff4cc0b6a25899d87ae9ee7 to your computer and use it in GitHub Desktop.
Save pascalandy/6bd6e60a9ff4cc0b6a25899d87ae9ee7 to your computer and use it in GitHub Desktop.
install docker engine for swarm3k on Ubuntu 16.04. 2 options for installing
#!/bin/sh
# option 2: paste this into user-data to automate install via boot script
# NOTE: update --label=owner=YOURNAME below if you want to easily identify yours
# renames the host to have a suffix of alexellisio
export original=$(cat /etc/hostname)
sudo hostname $original-alexellisio
echo $original-alexellisio | sudo tee /etc/hostname
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
mkdir -p /etc/apt/sources.list.d
echo deb https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list
printf 'net.ipv4.neigh.default.gc_thresh1 = 30000\nnet.ipv4.neigh.default.gc_thresh2 = 32000\nnet.ipv4.neigh.default.gc_thresh3 = 32768' >> /etc/sysctl.conf
sysctl -p
service lxcfs stop
apt-get remove -y -q lxc-common lxcfs lxd lxd-client
apt-get update -q
apt-get install -y -q linux-image-extra-$(uname -r) linux-image-extra-virtual
apt-get install -y -q docker-engine=1.12.3*
systemctl start docker.service
mkdir -p /etc/systemd/system/docker.service.d
printf '[Service]\nExecStart=\nExecStart=/usr/bin/dockerd -H fd:// --label=owner=alexellisio --storage-driver aufs' > /etc/systemd/system/docker.service.d/options.conf
systemctl daemon-reload
systemctl restart docker.service
usermod ubuntu -aG docker
docker swarm join \
--advertise-addr $(curl http://169.254.169.254/latest/meta-data/public-ipv4) \
--token SWMTKN-1-29tx6z2k8zmsbt9z2c2ay54jc9ce2l94ixhmmagveifv3pp4fa-5e8i9gugpb9b4bmi9vrp7m5su \
67.205.160.45:2377
#!/bin/bash
systemctl daemon-reload
systemctl restart docker.service
docker swarm leave --force
docker swarm join \
--advertise-addr $(curl https://api.ipify.org/?format=text) \
--token SWMTKN-1-29tx6z2k8zmsbt9z2c2ay54jc9ce2l94ixhmmagveifv3pp4fa-5e8i9gugpb9b4bmi9vrp7m5su \
67.205.160.45:2377
#!/bin/sh
export original=$(cat /etc/hostname)
sudo hostname $original-alexellisio
echo $original-alexellisio | sudo tee /etc/hostname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment