There is different ways to install docker on ubuntu. What method should I will use to install docker?? It will depends on your needs.
- Docker Engine comes bundled with Docker Desktop for Linux.
- Set up and install Docker Engine from Docker’s
apt
repository. - Install it manually and manage upgrades manually.
- Use a convenience scripts. Only recommended for testing and development environments.
Here I will use the second method. Use Docker apt repository for installation.
- Setup docker repository
i. Update the apt
package
sudo apt-get update
ii. Install packages to allow apt
to use a repository over https
sudo apt-get install ca-certificates curl gnupg
iii. Add Docker’s official GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
iv. Set up the repository
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
2. Install Docker Engine
i. Update the apt
package
sudo apt-get update
ii. Install Docker Engine, containerd, and Docker Compose
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
iii. Verify the Docker Engine installation
sudo docker run hello-world
After successfully installation you can see following result. When verify it using run “hello-world” docker image.
Reference
Thank You!