Created
January 27, 2024 17:26
-
-
Save dazeb/4d706270cf52851d45d8fa9e3c64555b to your computer and use it in GitHub Desktop.
Docker and Compose V2 BASH Installer
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 | |
# Update and Upgrade the System | |
echo "Updating and upgrading your system..." | |
sudo apt-get update && sudo apt-get upgrade -y | |
# Install required packages | |
echo "Installing packages required for Docker installation..." | |
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common lsb-release gnupg | |
# Add Docker’s official GPG key | |
echo "Adding Docker's official GPG key..." | |
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | |
# Set up the stable repository | |
echo "Setting up the Docker stable repository..." | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
# Update the apt package index | |
echo "Updating the apt package index..." | |
sudo apt-get update | |
# Install the latest version of Docker Engine and containerd | |
echo "Installing Docker Engine and containerd..." | |
sudo apt-get install -y docker-ce docker-ce-cli containerd.io | |
# Add current user to the Docker group | |
echo "Adding the current user to the Docker group..." | |
sudo usermod -aG docker $USER | |
# Install Docker Compose V2 | |
echo "Installing Docker Compose V2..." | |
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} | |
mkdir -p $DOCKER_CONFIG/cli-plugins | |
curl -SL https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-$(uname -s)-$(uname -m) -o $DOCKER_CONFIG/cli-plugins/docker-compose | |
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose | |
# Print Docker and Docker Compose versions | |
echo "Docker and Docker Compose V2 have been installed successfully." | |
docker --version | |
docker compose version | |
echo "You may need to log out and back in for the group changes to take effect." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment