How to install Docker and Docker compose

Googled777 avatar   
Googled777
A tutorial on how to install docker and docker compose


How to Install Docker & Docker Compose on Fresh Ubuntu

Install Docker & Docker Compose on Fresh Ubuntu

This tutorial walks you through installing Docker Engine and Docker Compose on a clean Ubuntu system. It follows the official repository method for maximum stability and future‑proofing.


1. Update Your System

sudo apt update
sudo apt upgrade -y

2. Install Required Dependencies

These packages allow apt to use repositories over HTTPS.

sudo apt install -y ca-certificates curl gnupg

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

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

5. Update Package Index

sudo apt update

6. Install Docker Engine

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

7. Enable & Start Docker

sudo systemctl enable docker
sudo systemctl start docker

8. Verify Docker Installation

docker --version
docker run hello-world
Tip: Running hello-world confirms that Docker Engine is working and can pull images.

9. Add Your User to the Docker Group (Optional)

This allows running Docker without sudo.

sudo usermod -aG docker $USER
newgrp docker

10. Install Docker Compose (Standalone Binary)

Ubuntu includes Docker Compose v2 as a plugin, but if you want the standalone binary:

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

11. Verify Docker Compose

docker compose version
docker-compose --version

12. Test Docker Compose

Create a simple test stack:

mkdir test-compose
cd test-compose

cat <<EOF > docker-compose.yml
version: "3.9"
services:
  hello:
    image: hello-world
EOF
Run it:
docker compose up

Done!

Your Ubuntu system now has a clean, stable Docker + Docker Compose setup ready for production, doctrine blocks, or containerized workflows.

0 Komentar

Tidak ada komentar yang ditemukan