Last active
October 23, 2019 18:10
-
-
Save dascenciohz/b399436262e633a13a0344f2ad6b4359 to your computer and use it in GitHub Desktop.
Shell Script Docker and docker-compose install to Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
##--- By Daniel Ascencio <daniel.ascencio.hz@gmail.com> ---## | |
COMPOSE_VERSION=$1 # 1.24.1 | |
SYSTEM_USER=$2 | |
PACKAGES="apt-transport-https ca-certificates curl gnupg-agent software-properties-common" | |
DOCKER_GPG="https://download.docker.com/linux/ubuntu/gpg" | |
DOCKER_URL="https://download.docker.com/linux/ubuntu" | |
DOCKER_PACKAGES="docker-ce docker-ce-cli containerd.io" | |
DOCKER_COMPOSE_VER=$COMPOSE_VERSION | |
DOCKER_COMPOSE_URL="https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VER/docker-compose" | |
DOCKER_NON_ROOT_USER=$SYSTEM_USER | |
## Uninstall old version | |
apt-get remove docker docker-engine docker.io containerd runc | |
## Install Docker Repository | |
## Install packages to allow apt to use a repository over HTTPS | |
apt-get update | |
apt-get -y install $PACKAGES | |
## Add Docker’s official GPG key | |
curl -fsSL $DOCKER_GPG | sudo apt-key add - | |
## Verify that you now have the key with the fingerprint | |
apt-key fingerprint 0EBFCD88 | |
## Set up the stable repository | |
add-apt-repository \ | |
"deb [arch=amd64] $DOCKER_URL \ | |
$(lsb_release -cs) \ | |
stable" | |
## Install Docker | |
apt-get update | |
apt-get -y install $DOCKER_PACKAGES | |
## Remove packages | |
apt-get -y autoremove | |
## Install Docker Compose | |
curl -L "$DOCKER_COMPOSE_URL-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
chmod +x /usr/local/bin/docker-compose | |
## Docker as a non-root user | |
usermod -aG docker $DOCKER_NON_ROOT_USER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment