Skip to content

Instantly share code, notes, and snippets.

@nirgeier
Created December 3, 2024 19:00
Show Gist options
  • Save nirgeier/a9f4b93ce7e656c85b222775345b5610 to your computer and use it in GitHub Desktop.
Save nirgeier/a9f4b93ce7e656c85b222775345b5610 to your computer and use it in GitHub Desktop.
Install_docker
#!/bin/bash
install_docker (){
OPTIONS=$(whiptail \
--title "Installation Methods" \
--menu "Oron the king" 25 78 16 \
"Docker" "Install Docker" \
"Nachman Was Here" "Nachman" \
"<-- Back" "Exit." \
3>&1 1>&2 2>&3)
# Check if OPTIONS variable is set to 'docker'
if [ "$OPTIONS" == "Docker" ];
then
echo "Installing Docker..."
# Update the package index
sudo apt update
# Install required dependencies
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
# Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Set up the Docker stable repository
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update the package index again
sudo apt update
# Install Docker CE (Community Edition)
sudo apt install -y docker-ce docker-ce-cli containerd.io
# Start and enable Docker to run on boot
sudo systemctl start docker
sudo systemctl enable docker
echo "Docker installation completed successfully!"
fi
}
install_docker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment