Install Docker Engine on Ubuntu
Install Docker Engine on Ubuntu
Set up the repository
- Update the
aptpackage index and install packages:
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
- 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
- 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
- Update the
aptpackage index, and install Docker Engine:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
- Verify that Docker Engine is installed correctly by running the
hello-worldimage.
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:
- Create the
dockergroup if it has not been created:
sudo groupadd docker
- Add your user to the
dockergroup.
sudo usermod -aG docker $USER
-
Log out and log back in so that your group membership is re-evaluated.
-
Verify that you can run
dockercommands withoutsudo.