Portainer allows you to manage your Docker containers with a graphical interface, working with Docker servers or Swarm clusters. Portainer consumes very few resources and runs as a Docker container itself (the Docker image is less than 4MB). Therefore, once we have Docker installed, it will be very easy to install.
Install Docker
As usual, before installing a package, make sure your server is up to date:
# apt update && apt upgrade -y
Install the necessary packages to be able to install Docker:
# apt install apt-transport-https ca-certificates curl software-properties-common
Add Docker's official GPG key:
# mkdir -p /etc/apt/keyrings
# curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Enable the Docker repository and update it:
# echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# apt update
Install the latest version of Docker:
# apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Install Portainer
As mentioned at the beginning of this article, installing Portainer is very simple since it runs within a Docker container. To do this, we will execute it:
# docker volume create portainer_data
# docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
Important
To access Portainer, you will need to open TCP port 9000 in your server's firewall to allow connections. For security reasons, it is recommended to open the port only to the public IP address of your internet connection. If you don't know how to enable a rule in your firewall profile, here is an article explaining How to create a firewall rule
Now that we have Portainer installed and the port open, the first step is to configure it. To do this, go to http://[SERVER_PUBLIC_IP]:9000, create a password for your admin user, select Local, and connect to your Docker container by clicking on Connect.
The next step will be to configure your server's IP. To do this, go to Environments and click on local. In the window that opens, you must enter your server's Public IP in the "Public IP" field. Below are some screenshots of the entire process:
Now that you have installed and configured Portainer, you can create any containers you want. You can do this in different ways: App Templates, Stacks, or Images > Containers.
Once you deploy a new container, it will appear in your Containers section:
Installing Portainer with SSL
If you want to configure Portainer with a domain name and SSL to have a secure connection without having to use the IP address, you can do so by following these steps.
The first step will be to install Certbot to generate a certificate with Let's Encrypt:
# apt install certbot -y
Then generate the certificate as follows:
# certbot certonly --standalone --preferred-challenges http -d [domain]
Finally, launch the Portainer container with the parameters required to run it using the SSL certificate:
docker run -d -p 443:9000 -p 8000:8000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer-data:/data -v /etc/letsencrypt/live/[domain]:/certs/live/[domain]:ro -v /etc/letsencrypt/archive/[domain]:/certs/archive/[domain]:ro portainer/portainer-ce:2.6.3 --ssl --sslcert /certs/live/[domain]/cert.pem --sslkey /certs/live/[domain]/privkey.pem
Important
Be sure to replace [domain] with the domain you have selected to access Portainer.
If you have any questions about this tutorial or any doubts regarding your cloud servers at Clouding, write to us at soporte@clouding.io We are right by your side to help you with whatever you need!