Portainer behind Traefik with docker-compose

What is Portainer?

Portainer is an open-source management tool for Docker. It offers an intuitive interface that makes managing Docker environments easier and makes it simple for users to develop, administer, and grow containerized applications.

It provides an intuitive interface that streamlines Docker container administration and facilitates user interaction with Docker resources.

Better visibility and control over the Docker environment are made possible, which offers a consolidated view of all Docker resources, including volumes, networks, images, and containers.

To support the upkeep and optimization of Docker setups, Portainer provides monitoring and logging services that offer insights into container performance and resource use.

In conclusion, Portainer is a useful solution for Docker users since it makes managing Docker environments easier, increases visibility and control, strengthens security, expedites deployment, and offers logging and monitoring features.

Getting Started

Requirements

To start with Portainer behined the Traefik you need to follow the instructions from the previous post.

Create your docker-compose.yml

## docker-compose.yml

version: '3.8'

networks:
 default:
   name: "traefik_net"
   external: true

services:
 portainer:
   image: "portainer/portainer-ce:alpine"
   container_name: "demo_portainer"
   hostname: "portainer.localhost"
   command: "-H unix:///var/run/docker.sock"
   volumes:
     - "/var/run/docker.sock:/var/run/docker.sock"
     - "data:/data"
   restart: always
   labels:
     # traefik
     - "traefik.enable=true"
     - "traefik.docker.network=traefik_net"
     - "traefik.http.routers.demo_portainer.rule=Host(`portainer.localhost`)"
     - "traefik.http.routers.demo_portainer.entrypoints=websecure"
     - "traefik.http.routers.demo_portainer.tls=true"
     - "traefik.http.services.demo_portainer.loadbalancer.server.port=9000"

volumes:
 data:
   name: "demo-portainer-data"

This configuration defines a network called "traefik_net" and shows it as an external network, which is the same as your traefik network. The portainer service specifies the use of the "portainer/portainer-ce:alpine" image.

It is called "demo_portainer" and is configured to use the hostname "portainer.localhost". The "Command" parameter specifies the communication mechanism with the Docker daemon.

Additionally, it sets up scopes and defines labels to enable Traefik integration, route traffic to services, and enable TLS.

Start your docker-compse.yml

Now you can start your service with:

docker compose up -d

now you can access the portainer user creation at https://portainer.localhost.

you can find the example on my git server.