Base de Conhecimento

How to Install Docker on Ubuntu

This guide walks you through installing Docker Engine on Ubuntu (22.04 / 24.04) from Docker’s official repository, which keeps you on the latest stable release.

1. Update the system and install prerequisites

sudo apt update
sudo apt install -y ca-certificates curl gnupg

2. 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

3. Add the Docker 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

4. Install Docker Engine

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

5. Enable and verify

sudo systemctl enable --now docker
sudo docker run hello-world

6. Run Docker without sudo (optional)

Add your user to the docker group, then log out and back in:

sudo usermod -aG docker $USER

Verify the version any time with docker --version and docker compose version.

Esta resposta foi útil?

0 Utilizadores acharam útil

Powered by WHMCompleteSolution