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 upgradeDocker Installation
Install required dependencies:
sudo apt-get install ca-certificates curl gnupgCreate the keyrings directory:
sudo install -m 0755 -d /etc/apt/keyringsAdd Docker's GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpgSet appropriate permissions:
sudo chmod a+r /etc/apt/keyrings/docker.gpgAdd 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 updateInstall Docker packages:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginOptional: Run Docker Without Sudo
Allow docker commands without elevated privileges:
sudo usermod -aG docker $USERPortainer Installation
Create a volume for Portainer data persistence:
docker volume create portainer_dataDeploy 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:latestThis 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.