How can Docker be installed on Ubuntu?

To install Docker on Ubuntu, you can follow these steps:

  1. Update the list of software packages:
sudo apt update
  1. Install dependencies for Docker and use HTTPS to download packages.
sudo apt install apt-transport-https ca-certificates curl software-properties-common
  1. Add the official GPG key for Docker.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  1. Add the stable repository for Docker.
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  1. Update the package list:
sudo apt update
  1. Install Docker Engine.
sudo apt install docker-ce docker-ce-cli containerd.io
  1. Verify if Docker has been successfully installed.
sudo docker run hello-world

If everything goes well, you will see the message “Hello from Docker!”, indicating that Docker has been successfully installed.

Please note that the steps above are based on the installation process for Ubuntu 20.04. If you are using a different version of Ubuntu, please adjust accordingly to your specific situation.

广告
Closing in 10 seconds
bannerAds