Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install docker and docker compose on Ubuntu
#!/usr/bin/env bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
set -e
docker_pre_install() {
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
}
docker_post_install() {
groupadd docker | true
usermod -aG docker ${USER}
}
docker_install() {
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
apt-get install -y docker-ce
}
docker_compose_install() {
curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
}
docker -v || {
docker_pre_install
docker_install
docker_post_install
}
docker-compose -v || {
docker_compose_install
}

Lightweight script to install Docker CE and docker-compose on Ubuntu.

To run script simply execute:

curl https://gist.githubusercontent.com/metallica127/a6c1960502ae8ef61782f527eed1e343/raw/51cbf65b1fe1e213725822354ad16c479b928239/install_docker_compose.sh | sudo bash -s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.