Skip to content

Install Docker Engine on Ubuntu

Install Docker Engine on Ubuntu

Set up the repository

  1. Update the apt package index and install packages:

sudo apt-get update
sudo apt-get install \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg \
     lsb-release 

  1. Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 
  1. Set up the repository
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 

Install Docker Engine

  1. Update the apt package index, and install Docker Engine:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io 
  1. Verify that Docker Engine is installed correctly by running the hello-world image.
sudo docker run hello-world 

Run docker commands without sudo

Docker Engine is installed and running. The docker group is created but no users are added to it. You need to use sudo to run Docker commands.

If Docker group is not created:

  1. Create the docker group if it has not been created:
sudo groupadd docker
  1. Add your user to the docker group.
sudo usermod -aG docker $USER 
  1. Log out and log back in so that your group membership is re-evaluated.

  2. Verify that you can run docker commands without sudo.