Skip to content

Instantly share code, notes, and snippets.

@kijart
Last active March 22, 2020 18:46
Show Gist options
  • Save kijart/bdd056becca2f14b9fb9f5c3b16d22b9 to your computer and use it in GitHub Desktop.
Save kijart/bdd056becca2f14b9fb9f5c3b16d22b9 to your computer and use it in GitHub Desktop.
Script for the setup and installation of Docker and Docker Compose in Debian & Ubuntu
#!/usr/bin/env bash
# Download and run interactive scripts: bash <(wget -qO- https://domain.url/path/install-docker.sh)
# Script for the setup and installation of Docker and Docker Compose in Debian
echo "You are going to execute a script for the setup and installation of Docker and Docker Compose in Debian"
echo "Are you sure?"
select yn in "Confirm" "Cancel"; do
case $yn in
Confirm ) break;;
Cancel ) echo "Aborting..."; exit 0;;
esac
done
# Update and upgrade Debian packages
sudo apt-get update && sudo apt-get -y upgrade
# Install some dependencies: packages to allow apt to use a repository over HTTPS
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
# Add Docker official GPG key
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"
# Update Debian packages repository
sudo apt-get update
# Install the latest version of Docker CE
sudo apt-get -y install docker-ce
# Download and install the latest version of Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose
# Add the current user to the docker group
sudo usermod -a -G docker $USER
# DONE!
echo "\nWe're done!!"
echo "- Logout and login again, so that the changes take effect"
echo "- It is recommended to restart the machine if there are important updates"
#!/usr/bin/env bash
# Download and run interactive scripts: bash <(wget -qO- https://domain.url/path/install-docker.sh)
# Script for the setup and installation of Docker and Docker Compose in Ubuntu
echo "You are going to execute a script for the setup and installation of Docker and Docker Compose in Ubuntu"
echo "Are you sure?"
select yn in "Confirm" "Cancel"; do
case $yn in
Confirm ) break;;
Cancel ) echo "Aborting..."; exit 0;;
esac
done
# Update and upgrade Ubuntu packages
sudo apt-get update && sudo apt-get -y upgrade
# Install some dependencies: packages to allow apt to use a repository over HTTPS
sudo apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
# Add Docker official GPG key
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"
# Update Ubuntu packages repository
sudo apt-get update
# Install the latest version of Docker CE
sudo apt-get -y install docker-ce
# Download and install the latest version of Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose
# Add the current user to the docker group
sudo usermod -a -G docker $USER
# DONE!
echo "\nWe're done!!"
echo "- Logout and login again, so that the changes take effect"
echo "- It is recommended to restart the machine if there are important updates"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment