HelperSheets/docker/InstallDockerCompose.md
2024-08-26 18:09:02 +02:00

1.5 KiB

Installing Docker and Docker Compose on Ubuntu as Root

Preparation

sudo apt update
sudo apt upgrade -y
sudo apt install -y ca-certificates curl gnupg lsb-release

Update packages, upgrade system, install required dependencies.

Add Docker Repository

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Add Docker's official repository and its GPG key.

Install Docker

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

Install Docker, its CLI, and required dependencies.

Verify Docker Installation

sudo docker run --rm hello-world

Run a test container to verify Docker installation.

Run Docker as Non-Root

Configure Permissions

sudo groupadd docker
sudo usermod -aG docker $USER

Create a docker group and add the current user.

Install Docker Compose

sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Download and install the latest Docker Compose binary.

Verify Docker Compose Installation

docker-compose --version

Display the installed Docker Compose version.