Created
August 2, 2023 16:17
-
-
Save dholdaway/61e5ffa52665d5a79d8f8daa7940b519 to your computer and use it in GitHub Desktop.
install docker Ubuntu 22.04
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 the package list | |
sudo apt-get update | |
# Install necessary packages | |
sudo apt-get install ca-certificates curl gnupg | |
# Create a directory for the keyring | |
sudo install -m 0755 -d /etc/apt/keyrings | |
# Download and install the Docker's official GPG key | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg | |
# Set permissions | |
sudo chmod a+r /etc/apt/keyrings/docker.gpg | |
# Add Docker's apt repository | |
echo "deb [arch=\"$(dpkg --print-architecture)\" signed-by=/etc/apt/keyrings/docker.gpg] 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 list | |
sudo apt-get update | |
# Install Docker packages | |
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | |
# Test Docker installation | |
sudo docker run hello-world | |
# Add a docker group | |
sudo groupadd docker | |
# Add the current user to the docker group | |
sudo usermod -aG docker $USER | |
# Enable Docker service to start on boot | |
sudo systemctl enable docker.service | |
# Disable containerd service to start on boot | |
sudo systemctl disable containerd.service | |
echo "Docker installation is complete." | |
echo "You might need to log out and log back in (or start a new shell session) after running this script to reflect the changes made by usermod." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment