Skip to content

Instantly share code, notes, and snippets.

@jishanshaikh4
Created December 2, 2021 03:34
Show Gist options
  • Save jishanshaikh4/9eebbb154bebebba0db886400167fcfa to your computer and use it in GitHub Desktop.
Save jishanshaikh4/9eebbb154bebebba0db886400167fcfa to your computer and use it in GitHub Desktop.
How to install docker in Ubuntu (Tested on 21.10)?
#!bin/bash
#########################################################
BASH SCRIPT TO INSTALL DOCKER ENGINE ON LINUX (UBUNTU)
Note: There might be some yes/no interactive prompts in the terminal.
#########################################################
# Uninstall old versions of docker, if available
sudo apt-get remove docker docker-engine docker.io containerd runc
# Install the dependencies
sudo apt-get update && sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
# Add docker's official keyring to local system
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Set up the stable repository
echo \
"deb [arch=$(dpkg --print-architecture) 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
# Install the latest version of the docker engine
sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io
# Verify the installation
sudo docker run hello-world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment