In this post, we will try to install Docker on Ubuntu 22.x Docker is a containerization platform
and Ubuntu is a Linux-based operating system.
Update the system
sudo apt update
It’s important to get the new updates on your operating system such that nothing breaks when we install software on the operating system.
Install the dependencies in Ubuntu
sudo apt install apt-transport-https curl gnupg-agent ca-certificates software-properties-common -y
You need to have the dependencies installed before installing the Docker.
In -y option in the apt install command will install the dependencies automatically without asking for Yes or No in the prompt
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 focal stable"
You need to add the above repository because docker binaries will be installed from here.
Install Docker in Ubuntu
sudo apt install docker-ce docker-ce-cli containerd.io -y
You will be installing the community edition of docker so we are using docker-ce and docker-ce-cli
sudo usermod -aG docker $USER
sudo chmod 666 /var/run/docker.sock
docker version
This will output the version of Docker.
Manage docker service
sudo systemctl status docker
You can check the status of the Docker daemon. This will help you to know that docker is running or not.
sudo systemctl start docker
You can start docker using the above command
sudo systemctl enable docker
When your operating system restarts/starts then Docker will automatically start if you enable it using the systemctl command
sudo systemctl restart docker
You can restart the docker daemon using the above command
References
Next Read: Ten Important Commands in Docker