Within our home server, all the applications we are going to run will be executed through Docker, specifically using docker-compose.
For that, we have two options: the first is to keep our docker-compose file with the entire configuration. The second is to have the Portainer application running inside that docker-compose, but then configure the rest of the applications from within Portainer itself.
1 - What is Portainer?
Portainer is a user interface for managing Docker containers. And the truth is that it does it very well and very simply, both in terms of ease of installation and in managing the containers themselves.
2 - Portainer VS Docker Desktop?
One reason might be that you do not want to pay for using Docker Desktop (the interface), since a few months ago it is paid for businesses. Portainer, meanwhile, has a community version that is free and can be used even if you are part of a business.
Another good reason is if you are not an advanced user, have little knowledge of containers or of computers in general, but need containers to set up your home server.
With Portainer, you can do this easily, since the interface allows us to add containers right from it.
Whereas with Docker Desktop we cannot modify or add anything through the interface, with Portainer we have a section for creating "stacks" that allow us to add the containers we want right from the UI. Of course, you will need the configuration for .yaml
.
Here, we can see an example with both interfaces running at the same time:
With Docker Desktop, the only alternative we have is to modify the docker-compose file ourselves; and in my case, editing the file on my Synology DS420+ is a bit tedious, because I have to access it via SSH. I am currently migrating from docker-compose
to Portainer because accessing the file has become a real hassle.
- Note: in my day-to-day work I still use Docker, but for my server, Portainer is much more comfortable.
2.1 - Installing Portainer
To install Portainer, we will have to do it in Docker or with docker-compose
, but it can easily be the only service we need to run there, and with the following code, we can run it:
portainer-ce:
image: portainer/portainer-ce:2.14.2
ports:
- 9444:9443 # https
container_name: portainer
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock #the first part referes to boot2docker in the VM
- D:\Server-config\portainer\data:/data #indica la tuya
To access Portainer, we have to do it via the SSL port. So, for now, since we do not have certificates, the browser will show a certificate warning, but just accept it.
The url is https://{ip-server}:9444/
and there we will need to create our main user.
2.2 - Installing a New Service With Portainer
To install a new service, the first thing we have to do is create a stack
And inside this stack, we configure the services we want. In my case I am only going to add overserr
:
Once we finish, click on "deploy the stack
" and once it is done we will be able to see the stack with the services running, and we can see several action buttons available:
And if we go to the URL http://{ip-server}:5055
we can see it loads without any problem.
Additionally, inside the Portainer interface itself, we have access to both the logs and the command line.
2.3 - Accessing Portainer
I want to highlight this: Portainer is a web application, so you can access it from your browser. I highly recommend having a super secure admin password (or configuring OAuth and setting up 2FA), as well as using a different, less privileged user for everyday use.
Each system resource can also have different access levels:
By default, there are 3 levels:
- Administrator: Only administrators can modify that particular resource.
- Restricted: You can limit its administration to a group of users, either one or several.
- Public: any user with access to the application will be able to administer the resource.
2.4 - Statistics in Portainer
One of my favorite features is the statistics for CPU and Memory usage. It is true that Docker Desktop shows the statistics of a specific container at the time you look, but Portainer keeps a chart, which is super helpful for monitoring in case any container is consuming too much.
Conclusion
In this post we have covered
- What Portainer is and how to configure it, with a simple example
- We have seen Portainer's main features
- A comparison between Docker Desktop and Portainer
- My personal opinion is that for a non-expert or a server, it is better to use Portainer than docker-compose, since the latter tends to be more tedious to maintain
- For professional work, I still prefer to do everything in the
docker-compose
file.
If there is any problem you can add a comment bellow or contact me in the website's contact form