Getting started with docker
Docker Installation in Ubuntu Linux
For the following Ubuntu Versions
- Ubuntu Jammy 22.04 (LTS)
- Ubuntu Impish 21.10
- Ubuntu Focal 20.04 (LTS)
- Ubuntu Bionic 18.04 (LTS)
If you have Older Docker version or already installed and went remove, then run the below commands
Docker Remove Commands
$ sudo apt-get remove docker docker-engine docker.io containerd runc
$ sudo rm -rf /var/lib/docker /etc/docker
$ sudo rm /etc/apparmor.d/docker
$ sudo groupdel docker
$ sudo rm -rf /var/run/docker.sock
above commands will remove docker completely from your system
Now let’s start installation of docker
First update your system
$ sudo apt-get update
Run below command to install packages to allow apt
to use a repository over HTTPS:
Add docker repositories in your ubuntu system
$ sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
Now add docker official GPG key’s in your ubuntu system for this create separate directory for docker
$ sudo mkdir -p /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Now add the Docker Repository to APT sources list
$ echo \ “deb [arch=$(dpkg –print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker Engine
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Now docker is installed, check the docker status
$ sudo systemctl status docker