Containers are perfect when you want to isolate your self-hosted services without the extra overhead of virtual machines. While the Docker CLI is the ideal way to manage your containers, running commands for simple operations can get tiresome at times. Docker Desktop is a decent option, but it’s rather rudimentary in its functionality.
That’s where Portainer comes in handy with its superior container management facilities. Whether you’re a fledgling home labber or a grizzled self-hosting veteran, here’s a detailed guide to help you deploy Portainer on your home server.
What’s Portainer anyway?
And why should you use it?
For the uninitiated, Portainer provides an intuitive web GUI to help you manage your containerized services. Rather than serving as a container runtime environment like Docker, Portainer extends Docker’s (and even Podman’s) functionality by allowing you to deploy, oversee, and troubleshoot your containers without terminal commands.
While Portainer is undoubtedly helpful for newcomers, it’s just as useful for advanced users, as you can access the image, network, user authentication, and registry settings from its convenient UI. Plus, it supports Kubernetes and Docker Swarm, and I daresay it’s the perfect option for managing container stacks in a Swarm-powered cluster.
I built a Kubernetes cluster with my Raspberry Pi's - here's how you can, too
A robust container orchestration server - built with a bunch of Raspberry Pi's and boundless patience
Deploying a Portainer instance
Since Portainer itself runs as a Docker container, you’ll need the container runtime environment pre-installed on your machine. Assuming you’re using a Linux distro,
- Open the terminal app built into the distribution.
-
Create persistent storage for your Portainer server with this command:
sudo docker volume create portainer_data
-
Execute the docker run command to deploy the Portainer container:
sudo 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:2.21.5
Accessing the Portainer web UI
Once you’ve got the Portainer container up and running, it’s time to access its web UI. To do so,
- Type the IP address of the PC running Portainer followed by a colon (:) and the port number 9443 into your web browser. If you’re using the same PC, you can switch the IP address with the localhost string. Since Portainer automatically generates the SSL certificate for the container, you’ll have to use the https protocol instead of plain ol' http.
- Enter a Password for your Portainer server and tap Create User.
- Your local Docker node (the one running the Portainer server) will be visible under the Environments tab, and you can link it with your Portainer UI by clicking on the Live connect button.
If you’re new to Portainer, here are some tips to help you manage containers like a pro:
- The Containers tab will reveal the Status, Image, IP Address, Port Number, and other stats of your services, similar to the results of running the docker container ls command.
- You can click on the New Container button within this tab and add the Name and Image for the service you seek to deploy as a container. Be sure to specify the TCP/UDP ports for the container.
- Meanwhile, the Images tab lets you pull images from the Docker Hub, though you can also build your own image if you’re familiar with Dockerfile syntax.
- If you want a straightforward means to self-host apps, you can access the container templates within the Templates header. Like images, you can also specify your own container templates inside Portainer.
- The Environment-related tab under the Administration section is useful when you want to link other Docker, Kubernetes, Docker Swarm, or ACL instances with your Portainer UI.
- If you wish to allocate persistent storage to your containers, you can do so within the Volume tab.
- Finally, the Network tab lets you fine-tune the virtual networks for your containers and is especially useful when you want your services to communicate with each other.
Mastering containerization with Portainer’s simple UI
Apart from the options I've highlighted so far, there are multiple other tabs, menus, and settings you can tweak to enhance your containerization game in Portainer. The Activity section, for instance, is extremely useful when you want to troubleshoot a faulty container, while the Edge Compute tab is for advanced users who want to integrate edge devices into their container hub.
The only caveat about Portainer is that the free community edition offers limited functionality in Kubernetes setups. But if you’re just looking for an easy web UI to manage a handful of local Docker environments, you’ll have no issues with Portainer.
25 essential commands every Docker user should know
Docker's command-line interface may seem intimidating, but these commands can help you master it in no time!
