Why do you need Portainer

It will make your life easier when managing containers through an UI instead of the CLI.

And yes, Containers are a great way to start your SelfHosting Journey (Trust me you need them).

Portainer - Docker container

Not surprisingly, we can install Portainer with a Docker Container.

So we will install Docker and Portainer with CLI and then forget about it from that point, deploying new services with docker-compose files in the stack.

Docker - First steps

One recurrent topic that has to be addressed in the first place is to setup Docker in our machine.

Basically you will need to perform this in Linux (There is an equivalent for Windows or mac)

apt-get update && sudo apt-get upgrade && curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh && docker version

Deploy Portainer

SelfHosting Portainer with Docker

We will be using one single command:

sudo docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

# podman run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

Now you will be able to access Portainer interface on the port 9000 of your machine and manage containers from the UI. Also you will be able to deloy new ones with Stacks (using docker-compose on the interface).

This will be the user Setup page:

Portainer Login UI

And then you can manage your containers with UI:

Portainer Docker UI


FAQ

F/OSS Alternatives to Portainer

  • Dockge with Docker

How to backUP Portainer

sudo fdisk -l #get the drive
sudo mkdir /mnt/external_500gb
sudo mount /dev/sda1 /mnt/external_500gb #mount the drive

mkdir /mnt/external_500gb/Z_SelfH_Backup/portainer_data/_data/
sudo cp -r /mnt/portainer_backup/var/lib/docker/volumes/portainer_data/_data/* /mnt/external_500gb/Z_SelfH_Backup/portainer_data/_data/

And to recover, just:

docker volume inspect portainer_data #see where the named volume is stored and use it as destination

sudo cp -r /mnt/data_ntfs_500/Z_SelfH_Backup/portainer_data/_data/* /var/lib/docker/volumes/portainer_data/_data/