Docker and Portainer Install Tutorial

Installing Docker, Docker Compose, and Portainer on Ubuntu

Prerequisites

  • A system running Ubuntu (20.04, 22.04, or later).
  • A user with sudo privileges.

Step 1: Update the System

1
sudo apt update && sudo apt upgrade -y

Step 2: Install Required Dependencies

1
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

Step 3: Install Docker

Add Docker’s Official GPG Key:

1
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Add the Docker Repository:

1
echo "deb [arch=$(dpkg --print-architecture) 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
2
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io

Verify Docker Installation:

1
docker --version

Enable and Start Docker Service:

1
sudo systemctl enable --now docker

Add Your User to the Docker Group (Optional):

1
2
sudo usermod -aG docker $USER
newgrp docker

Step 4: Install Docker Compose

Download and Install Latest Version:

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

Apply Executable Permissions:

1
sudo chmod +x /usr/local/bin/docker-compose

Verify Installation:

1
docker-compose --version

Step 5: Install Portainer

Create a Docker Volume for Portainer:

1
docker volume create portainer_data

Deploy Portainer Container:

1
2
3
4
5
6
7
docker run -d \
--name=portainer \
--restart=always \
-p 8000:8000 -p 9443:9443 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:latest

Access Portainer Web UI:

Open a web browser and go to:

1
https://<your-server-ip>:9443

Create an admin account and start managing your containers.


Conclusion

You have successfully installed Docker, Docker Compose, and Portainer on Ubuntu. 🎉 Happy containerizing!