Skip to content

Instantly share code, notes, and snippets.

@themaleem
Last active June 27, 2022 12:44
Show Gist options
  • Save themaleem/58e7e7fd9a01f07b4841543246af6fde to your computer and use it in GitHub Desktop.
Save themaleem/58e7e7fd9a01f07b4841543246af6fde to your computer and use it in GitHub Desktop.
install docker on ubuntu; shell script
#!/bin/sh
#
# Docker install script
#
# Run this script with Administration priviledges (sudo)
#
echo "------------ Install pre-requisites ---------------------"
# Install packages to allow apt to use a repository over HTTPS:
apt-get install 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 apt-key add
# Print the key fingerprint to verify it is: 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
apt-key fingerprint 0EBFCD88
echo "------------ Set and update repository ------------------"
# Set up the stable repository:
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
echo "------------ Install and test docker -------------------"
# Install the latest version of Docker:
apt-get install docker-ce
#add user to docker group to avoid use of sudo (remember to exit and re-open bash)
sudo usermod -aG docker $(whoami)
# Verify that Docker is installed correctly by running the hello-world image
sudo docker run hello-world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment