Back to Blog
tutorialBeginner5 min read

Install Docker and Portainer on Ubuntu

A step-by-step guide to installing Docker and Portainer on Ubuntu, covering system updates, Docker repository setup, and deploying the Portainer container for graphical Docker management.

Ubuntu - Docker & Portainer Installation

Initial System Setup

Begin by updating your Ubuntu system to ensure all packages are current:

sudo apt update && sudo apt upgrade

Docker Installation

Install required dependencies:

sudo apt-get install ca-certificates curl gnupg

Create the keyrings directory:

sudo install -m 0755 -d /etc/apt/keyrings

Add Docker's GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Set appropriate permissions:

sudo chmod a+r /etc/apt/keyrings/docker.gpg

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
sudo apt-get update

Install Docker packages:

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

Optional: Run Docker Without Sudo

Allow docker commands without elevated privileges:

sudo usermod -aG docker $USER

Portainer Installation

Create a volume for Portainer data persistence:

docker volume create portainer_data

Deploy Portainer container:

docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

This command creates a container using ports 8000 and 9443, names it 'portainer', enables automatic restart, and mounts necessary volumes.

Accessing Portainer

On Ubuntu Server, access Portainer from another machine on the network using the host IP and port 9443. For Ubuntu Desktop, navigate to:

https://localhost:9443

Configure your admin credentials on first access. Click "Get Started" to manage your Docker environment through the graphical interface. Portainer enables container management and stack deployment for multi-container applications.