How do you install Docker on Ubuntu?

To install Docker on Ubuntu, follow these steps:

  1. Update the system software package list:
sudo apt update
  1. Install the dependencies for Docker.
sudo apt install apt-transport-https ca-certificates curl gnupg-agent 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. Set up a stable version 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 list of software packages:
sudo apt update
  1. Install Docker Engine.
sudo apt install docker-ce docker-ce-cli containerd.io
  1. Check to see if Docker has been successfully installed.
sudo docker run hello-world

If everything goes smoothly, you should be able to see Docker run a Hello World container and output the relevant information.

Please note that these instructions are for Ubuntu 20.04 and later versions. For older versions of Ubuntu, you may need to refer to specific installation instructions in the official Docker documentation.

bannerAds