Ubuntu 18.04 - Install Docker
The script below will install docker using a PPA. This will allow you to always use the latest version of Docker without waiting on the Ubuntu package maintainers. Normally I would recommend installing from the Ubuntu Repos, but with docker this method is what I recommend.
Related Posts
Steps
#!/bin/bash
# Stop script on any error
set -e
sudo apt update && sudo apt dist-upgrade -y
# Remove any existing installations...
sudo apt-get purge docker-engine -y
sudo apt-get remove docker docker-engine docker.io -y
sudo apt update
sudo apt install -y \
software-properties-common apt-transport-https ca-certificates curl
# Add the key for docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt update
sudo apt install docker-ce -y
# Add the current user to docker so that you can
# execute docker commands without using sudo
sudo usermod -aG docker $USER
echo "You will need to reboot before using docker."
References
- Docker Installation Docs - Ubuntu
- DigitalOcean - How To Install and Use Docker on Ubuntu 16.04
- How to completely uninstall docker from ubuntu
Last updated: 21st February 2021
First published: 16th August 2018
First published: 16th August 2018