#!/bin/bash if [ -n "`grep Amazon /etc/os-release | head -n1`" ]; then echo "Assuming Amazon Linux" sudo yum update -y sudo yum install docker -y sudo systemctl start docker && sudo systemctl enable docker sudo usermod -a -G docker ec2-user elif [ -n "`grep Debian /etc/os-release`" ]; then echo "Assuming Debian Linux" sudo apt-get update sudo apt-get install -y \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/debian \ $(lsb_release -cs) \ stable" sudo apt-get update sudo apt-get install -y docker-ce docker-ce-cli containerd.io elif [ -n "`grep Ubuntu /etc/os-release`" ]; then echo "Assuming Ubuntu" sudo apt-get update sudo apt-get install -y \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io else echo "Assuming CentOS/RHEL" sudo yum install -y yum-utils sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo sudo yum install -y docker-ce docker-ce-cli containerd.io sudo systemctl start docker && sudo systemctl enable docker fi