In this article, we’ll look at how to install Portainer on Ubuntu.
Portainer gives users a way to manage their Docker containers through a great web interface. For my Raspberry Pi and Ubuntu Docker instances, I always use Portainer to manage my containers as I find it to be the easiest application to use.
Portainer also gives you the ability to use stacks which is an easy way to create new containers and allows them to be created using a docker-compose format.
If you haven’t used docker-compose before, it’s just an easy way to copy/paste pretty much all of the configurations you’ll need for a container and create it with the push of a button.
How to Install Portainer on Ubuntu
Before you install Portainer on Ubuntu, you must ensure that you have Docker installed on Ubuntu first.
Please note that the instructions below must be performed on Ubuntu 22.04 or greater. If you’d like to install Docker on Ubuntu 20.04, the instructions can be found here.
Installing Docker on Ubuntu
The instructions on how to install Docker on Ubuntu are pasted below but are pulled directly from the official Docker instructions.
1. Start by updating the Ubuntu operating system.
sudo apt update && sudo apt upgrade -y
2. To Install Docker, run the commands below, one by one, and in order.
sudo apt-get install ca-certificates curl gnupg
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
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
3. Install Docker, then enable the Docker service by running the commands below.
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo service docker start
4. Docker is now installed and can be accessed through the command-line interface. However, Portainer isn’t configured yet, so we’ll look at that below.
Installing Portainer on Ubuntu
Now that Docker is installed, we can install Portainer by running the commands below.
1. Download and run the Portainer Docker container by running the commands below.
sudo docker run -d -p 8000:8000 -p 9000:9000 -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
2. This will install Docker and it will be accessible by the workstation’s IP address and port 9000 for HTTP or the workstation’s IP address and port 9443 for HTTPS. When you get there, create a username and password.
HTTP: http://[WORKSTATION_IP_ADDRESS]:9000 HTTPS: https://[WORKSTATION_IP_ADDRESS]:9443
3. Select Get Started to access Portainer.
4 Select Local to gain access to Portainer.
5. Portainer is now installed!
Portainer Volume Mapping
When you install Portainer, the Docker run command will automatically install it to a volume. Using the command below, the volume is listed in red (portainer_data).
sudo docker run -d -p 8000:8000 -p 9000:9000 -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
If you’d ever like to update Portainer, you must use the same volume as listed above to maintain your Portainer configuration. If you’d ever like to move Portainer to a new server, the volume files can be found and accessed using the command below.
sudo docker volume inspect portainer_data
Using the example above, the /var/lib/docker/volumes/portainer_data/_data location will hold all the important Portainer files and can be accessed/moved to a different server if desired.
Conclusion: How to Install Portainer on Ubuntu
This tutorial looked at how to install Docker and Portainer on Ubuntu. Overall, the process of installing Portainer on Ubuntu is fairly straightforward, but is a little more complicated on Ubuntu 22.04 than it was on Ubuntu 20.04.
However, if you simply run the commands above from the terminal, you’ll get it installed quickly and efficiently.
Thanks so much for checking out the tutorial on how to install Portainer on Ubuntu. If you have any questions, please leave them in the comments!