Installation of Container Manager Portainer behind Traefik

This guide is about the container manager Portainer, which is to be set up behind Traefik as a reverse proxy manager.

Installation of Container Manager Portainer behind Traefik-heroimage

Table of Contents

CAUTION

Please note that this blog post was originally written in German and has been translated for your convenience. Although every effort has been made to ensure accuracy, there may be translation errors. I apologize for any discrepancies or misunderstandings that may result from the translation and I am grateful for any corrections in the comments or via mail.

I generally prefer to control my Docker containers directly via my server or use Lazydocker for visual help. However, sometimes (especially on the road) it is also convenient not to have to establish an SSH connection to the server in order to manage certain containers or view the logs. This is where Portainer comes into play.

Portainer | Open Source Container Management GUI for Kubernetes, Docker, Swarm Portainer is the definitive open source container management GUI for Kubernetes, Docker, Swarm and ACI.

Traefik should be set up as a reverse proxy for my configuration file, as described here. Then we need a folder for the data and the Docker-Compose file.

cd ~/docker
mkdir appdata/portainer/data -p
nano docker-compose-portainer.yml

We add the following text to this file.

version: "3.7"

### NETWORKS ###
networks:
    web:
        external:
            name: web
    default:
        driver: bridge

### Services ###
services:
    portainer:
        container_name: portainer
        image: portainer/portainer-ce:latest
        restart: unless-stopped
        command: -H unix:///var/run/docker.sock
        networks:
            - web
        security_opt:
            - no-new-privileges:true
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock:ro
            - $DOCKERDIR/appdata/portainer/data:/data
        environment:
            - TZ=$TZ
        labels:
            - "traefik.enable=true"
            - "traefik.http.routers.portainer-rtr.entrypoints=https"
            - "traefik.http.routers.portainer-rtr.rule=Host(`portainer.$DOMAINNAME`)"
            - "traefik.http.routers.portainer-rtr.tls=true"
            # - "traefik.http.routers.portainer-rtr.middlewares=chain-basic-auth@file" # Basic Authentication
            - "traefik.http.routers.portainer-rtr.middlewares=chain-oauth@file" # Google Authentication
            - "traefik.http.routers.portainer-rtr.service=portainer-svc"
            - "traefik.http.services.portainer-svc.loadbalancer.server.port=9000"

We use the official image.

docker-compose -f docker-compose-portainer.yml up -d

Done. Portainer should now be visible under our Portainer subdomain.

An update to a later release can also be carried out very easily.

docker-compose -f docker-compose-portainer.yml pull
docker-compose -f docker-compose-portainer.yml down
docker-compose -f docker-compose-portainer.yml up -d

This website uses cookies. These are necessary for the functionality of the website. You can find more information in the privacy policy