Created
January 28, 2024 13:45
-
-
Save dazeb/da03dc06bd1bdb80ee6a52f87ad5d8e2 to your computer and use it in GitHub Desktop.
Install Docker using repo
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 | |
# Ensure the script is run as root | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
# Update the package index | |
echo "Updating package index..." | |
sudo apt-get update | |
# Install prerequisites | |
echo "Installing ca-certificates and curl..." | |
sudo apt-get install -y ca-certificates curl | |
# Create the directory for the keyring if it doesn't already exist | |
echo "Creating /etc/apt/keyrings directory..." | |
sudo install -m 0755 -d /etc/apt/keyrings | |
# Add Docker's official GPG key | |
echo "Adding Docker's official GPG key..." | |
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | |
sudo chmod a+r /etc/apt/keyrings/docker.asc | |
# Add the Docker repository to Apt sources | |
echo "Adding the Docker repository to Apt sources..." | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
# Update the package index with the new repository | |
echo "Updating package index with the Docker repository..." | |
sudo apt-get update | |
echo "Docker repository setup is complete. You can now install Docker." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment