Skip to content

Instantly share code, notes, and snippets.

@alexellis
Forked from BretFisher/copy-paste.txt
Last active August 31, 2023 21:52
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 27 You must be signed in to fork a gist
  • Save alexellis/189cfeed58e94066106b486b76b4c015 to your computer and use it in GitHub Desktop.
Save alexellis/189cfeed58e94066106b486b76b4c015 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-master-alexellisio
echo $original-master-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 init \
--listen-addr=eth0
--advertise-addr $(curl http://169.254.169.254/latest/meta-data/public-ipv4) >> /home/ubuntu/swarm.key
#!/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-51tzjz9elca64uwwzs99kgv8x2eboqs1ssiso8awmaq789tjbw-cgcobtsj12op8d0ewdyxdjypy \
172.31.50.194:2377
#!/bin/bash
systemctl daemon-reload
systemctl restart docker.service
docker swarm leave --force
site=$(curl -s https://api.ipify.org/?format=text) echo $site docker swarm join --advertise-addr $site \
--token SWMTKN-1-2nle9d1yoocuhtchkx9m1uba0xs8uwwquj1dq1v5ipjgp4fka5-aabs7ghllav8g7wjbv62zz3tp \
172.31.62.216: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