install docker on ubuntu 20.04
Simple docker step by step how to install docker on ubuntu 20.04 with explanation
Surely you want to take advantage of all the benefits Docker offers for containerization of your projects: here’s a simple guide to installing Docker on Ubuntu 20.04.
Prerequisites
Before starting the Docker installation process, you need to set up the server. This means having a non-root user account on an Ubuntu 20.04 server with sudo privileges.
Step 1: Update the Software Repository
Firstly, update your existing list of software.
Open a terminal:
sudo apt-get update
This downloads an updated index of available packages.
Step 2: Uninstall Old Docker Versions
Older versions of Docker, labeled as ‘docker’ or ‘docker-engine’, should be removed:
sudo apt-get remove docker docker-engine docker.io containerd runc
If the system says that none of these packages are available, that’s fine. It just means Docker wasn’t installed yet.
Step 3: Installation of Docker on Ubuntu
Now, install Docker with this command:
sudo apt-get install docker.io
After the software is installed, check the installed version:
docker --version
This shows which version of Docker is installed on your machine.
Step 4: Run Docker as a non-root user
Normally, Docker needs administrator privileges. To run Docker commands as a non-root user without using ‘sudo’, add your user to the ‘docker’ group:
sudo usermod -aG docker $USER
You may need to log out and back in so the group membership is re-evaluated.
Step 5: Verify the Docker Installation
Start the Docker service:
sudo systemctl start docker
sudo systemctl enable docker
These commands start the Docker service and ensure it runs at startup.
Now, verify Docker works fine:
docker run hello-world
This command downloads a test image and runs it in a container. If it prints out a message, your Docker installation is correctly running.
With Docker now installed on your Ubuntu 20.04 system, you can start building, managing, and distributing Docker containers. There are numerous Docker images available from the Docker hub, making Docker all the more useful. Happy Dockering!