Docker is container application that makes you easy to install your app in any operating systems. Containers are a standardized unit of software that allows developers to isolate their app from its environment. I recently doing some testing that involve deploying a lot of numbers of virtual machine EC2 instances on AWS and my local workstations.
Install docker Ubuntu 20.04 distribution using apt install or snap never works for me, so I always go to docker website and go to their installation instructions page.
They have a good and working instructions to install Docker on Ubuntu 20.04 and I can just copy paste the command, but after sometimes I become more lazy because I have to copy paste one instructions at a time. I just want to copy the whole instruction at once very quick and run in on my terminal at once.
So here it is. I put the whole instructions in one place, so me and hopefully you can use it.
Commands To Install Docker
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
sudo docker run hello-world
sudo curl -L "https://github.com/docker/compose/releases/download/1.28.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
The first line the command above delete existing docker installation on your Ubuntu then update the package manager and install necessary packages.
The command in line 12 adds docker repository into your package manager and update the Ubuntu package manager again, so it includes new addition of Docker repository. The next line is where the command line install docker.
In line 18 the command Docker run will run hello-world image. If you never pull this hello-world image docker will automatically pull the image from Docker hub.
Upgrade Docker
In the command above you will install the latest docker. If you need to update docker, simply run apt upgrade
sudo apt --only-upgrade docker-ce docker-ce-cli containerd.io
On the last 2 lines, line 19 and line 20, the command will download docker-compose and install it on /usr/local/bin. Note the docker-compose version 1.28.2, you may later need to change the version to latest one.
What’s next? try running docker your self with this docker examples using python with rest api.