Skip to content

Instantly share code, notes, and snippets.

@shorefall
Created April 30, 2024 11:56
Show Gist options
  • Save shorefall/46e9a7d383871e2d1fe755d1d749b87b to your computer and use it in GitHub Desktop.
Save shorefall/46e9a7d383871e2d1fe755d1d749b87b to your computer and use it in GitHub Desktop.
DockerInstall.sh
#!/bin/bash
# Remove any old versions
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do
sudo apt-get remove -y $pkg
done
# Update package index and install prerequisites
sudo apt-get update
sudo apt-get install -y ca-certificates curl
# Add Docker's official GPG key
sudo install -m 0755 -d /etc/apt/keyrings
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 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 package index with new repository and install Docker
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Verify installation by running the Hello World example
sudo docker run hello-world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment