Skip to content

Instantly share code, notes, and snippets.

@carljdp
Last active April 23, 2018 11:40
Show Gist options
  • Save carljdp/a6a7782ccc75e5195892d12473e5503d to your computer and use it in GitHub Desktop.
Save carljdp/a6a7782ccc75e5195892d12473e5503d to your computer and use it in GitHub Desktop.
Docker Installation Scripts
#!/bin/bash
# Removes all Docker cintainers, images, and Docker itself.
# see http://blog.baudson.de/blog/stop-and-remove-all-docker-containers-and-images
echo "Removing all containers and images.."
sudo docker stop $(sudo docker ps -aq)
sudo docker rm $(sudo docker ps -aq)
sudo docker rmi $(sudo docker images -q)
echo "Removing Docker-CE.."
sudo apt-get remove -y docker docker-engine docker.io docker-ce
sudo apt-get purge -y docker docker-engine docker.io docker-ce
sudo apt-get autoremove -y --purge docker docker-engine docker.io docker-ce
sudo apt-get autoclean
echo "Removing Docker artifacts"
sudo rm -rf /var/lib/docker*
sudo rm -rf /etc/docker*
sudo groupdel docker
echo "Remaining artifacts should automatically be removed by a reboot.."
#!/bin/bash
echo "Supports Rancher v1.6"
ufw allow OpenSSH
# Open Rancher Server ipsec ports
ufw allow 500/udp
ufw allow 4500/udp
ufw enable
ufw status
echo "Now run the Rancher Custom script"
echo "https://rancher.com/docs/rancher/v1.6/en/hosts/custom/"
#!/bin/bash
echo "Supports Rancher v1.6"
# open port for Rancher Server UI
ufw allow 8080/tcp
# Setup Rancher Server bind mount volume for MySQL
mkdir -p /data/rancher-server/mysql
sudo chown -R 102:105 /data/rancher-server
sudo docker run -d \
-v /cdata/rancherserver/mysql:/var/lib/mysql \
-e CATTLE_PROMETHEUS_EXPORTER=true \
-p 8080:8080 \
-p 9108:9108 \
--restart=unless-stopped \
rancher/server:stable
#!/bin/bash
echo "Supports Rancher v1.6"
# stop at the first error
set -e
# Refer to this page for supported Docker version in Rancher
# https://rancher.com/docs/rancher/v1.6/en/hosts/#supported-docker-versions
console_log() {
set +x
echo "┆"
echo "├───────────────────────────────────────"
echo "├╼ $1"
echo "┆"
# print commands before execution
set -x
}
echo ========================================
echo Script: ubuntu-install-docker-ce.sh
echo Author: carljdp
echo ----------------------------------------
console_log "Checking requirements"
# Check if root
userId=$(id -u)
if [ "$userId" -ne 0 ]
then
echo "Run with sudo"
exit 1
fi
# Check if amd64
arch=$( uname -m )
if [ "$arch" != "x86_64"]
then
echo "$arch not currently supported"
exit 1
fi
console_log "Uninstall old versions"
apt-get remove docker docker-engine docker.io
console_log "Setup the Repository"
apt-get update
apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
console_log "Add Docker’s official GPG key"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
console_log "Verify that you now have the key with the fingerprint"
apt-key fingerprint 0EBFCD88
console_log "set up the stable repository"
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
#console_log "Install latest version of Docker CE"
#apt-get install docker-ce -y
console_log "Install Docker v17.12.1~ce tested with Rancher >= v1.6.14"
apt-get install docker-ce=17.12.1~ce-0~ubuntu -y
console_log "Verify that Docker CE is installed correctly"
docker run hello-world --rm
console_log " D O N E ! "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment