Portainer Templates logo

Portainer Templates

Authentik Authentik

Stack

ToolsAuthentication

Authentik is an open-source Identity Provider focused on flexibility and versatility

Configuration

Type
Compose
Platform
linux
Env vars
PUID=1000PGID=1000PORT=''
Source

Template by xneo1·Source

Services

postgresql

Configuration

Image
postgres:12-alpine
Volumes
/var/lib/postgresql/data : database
Env vars
POSTGRES_PASSWORD=${PG_PASS:?database password required}POSTGRES_USER=${PG_USER:-authentik}POSTGRES_DB=${PG_DB:-authentik}
Restart
unless-stopped

Image details

Pulls: 11.2B
User: stackbrew
Created: Jun 05, 2014
Updated: 1 hour ago
Status: active

redis

Configuration

Image
redis:alpine
Restart
unless-stopped

Image details

Pulls: 11.1B
User: stackbrew
Created: Jun 05, 2014
Updated: 9 days ago
Status: active

server

Configuration

Image
${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2021.12.5}
Command
server
Ports
0.0.0.0:${AUTHENTIK_PORT_HTTP:-9000}:90000.0.0.0:${AUTHENTIK_PORT_HTTPS:-9443}:9443
Volumes
/media : ./media/templates : ./custom-templates/geoip : geoip
Env vars
AUTHENTIK_REDIS__HOST=redisAUTHENTIK_POSTGRESQL__HOST=postgresqlAUTHENTIK_POSTGRESQL__USER=${PG_USER:-authentik}AUTHENTIK_POSTGRESQL__NAME=${PG_DB:-authentik}AUTHENTIK_POSTGRESQL__PASSWORD=${PG_PASS}
Restart
unless-stopped

worker

Configuration

Image
${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2021.12.5}
Command
worker
Volumes
/backups : ./backups/media : ./media/certs : ./certs/var/run/docker.sock : /var/run/docker.sock/templates : ./custom-templates/geoip : geoip
Env vars
AUTHENTIK_REDIS__HOST=redisAUTHENTIK_POSTGRESQL__HOST=postgresqlAUTHENTIK_POSTGRESQL__USER=${PG_USER:-authentik}AUTHENTIK_POSTGRESQL__NAME=${PG_DB:-authentik}AUTHENTIK_POSTGRESQL__PASSWORD=${PG_PASS}
Restart
unless-stopped

geoipupdate

Configuration

Image
maxmindinc/geoipupdate:latest
Volumes
/usr/share/GeoIP : geoip
Env vars
GEOIPUPDATE_EDITION_IDS=GeoLite2-CityGEOIPUPDATE_FREQUENCY=8

Image details

Pulls: 31.5M
User: maxmindinc
Created: Apr 16, 2020
Updated: 1 month ago
Status: active

Standalone Install

Select an install method, to see config/commands for deploying Authentik

Installation method

Install on Portainer

Import all app templates into your Portainer instance, for easy 1-click deploys

  1. Ensure both Docker and Portainer are installed, and up-to-date
  2. Log into your Portainer web UI
  3. Under Settings → App Templates, paste the below URL
  4. Head to Home → App Templates, and the list of apps will show up
  5. Select Authentik, fill in any config options, and hit Deploy

Template Import URL

https://raw.githubusercontent.com/Lissy93/portainer-templates/main/templates.json
Show Me demo
Original stackfile

The compose file this template deploys, straight from its repo:

services:
  postgresql:
    image: postgres:12-alpine
    restart: unless-stopped
    volumes:
      - database:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=${PG_PASS:?database password required}
      - POSTGRES_USER=${PG_USER:-authentik}
      - POSTGRES_DB=${PG_DB:-authentik}
    env_file:
      - .env
  redis:
    image: redis:alpine
    restart: unless-stopped
  server:
    image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2021.12.5}
    restart: unless-stopped
    command: server
    environment:
      AUTHENTIK_REDIS__HOST: redis
      AUTHENTIK_POSTGRESQL__HOST: postgresql
      AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}
      AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}
      AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}
      # AUTHENTIK_ERROR_REPORTING__ENABLED: "true"
      # WORKERS: 2
    volumes:
      - ./media:/media
      - ./custom-templates:/templates
      - geoip:/geoip
    env_file:
      - .env
    ports:
      - "0.0.0.0:${AUTHENTIK_PORT_HTTP:-9000}:9000"
      - "0.0.0.0:${AUTHENTIK_PORT_HTTPS:-9443}:9443"
  worker:
    image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2021.12.5}
    restart: unless-stopped
    command: worker
    environment:
      AUTHENTIK_REDIS__HOST: redis
      AUTHENTIK_POSTGRESQL__HOST: postgresql
      AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}
      AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}
      AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}
      # AUTHENTIK_ERROR_REPORTING__ENABLED: "true"
    # This is optional, and can be removed. If you remove this, the following will happen
    # - The permissions for the /backups and /media folders aren't fixed, so make sure they are 1000:1000
    # - The docker socket can't be accessed anymore
    user: root
    volumes:
      - ./backups:/backups
      - ./media:/media
      - ./certs:/certs
      - /var/run/docker.sock:/var/run/docker.sock
      - ./custom-templates:/templates
      - geoip:/geoip
    env_file:
      - .env
  geoipupdate:
    image: "maxmindinc/geoipupdate:latest"
    volumes:
      - "geoip:/usr/share/GeoIP"
    environment:
      GEOIPUPDATE_EDITION_IDS: "GeoLite2-City"
      GEOIPUPDATE_FREQUENCY: "8"
    env_file:
      - .env

volumes:
  database:
    driver: local
  geoip:
    driver: local

Or deploy it directly from the source:

git clone https://github.com/xneo1/portainer_templates
cd portainer_templates
docker compose -f Template/Stack/authentik.yml up -d

More install options in our documentation.

Container Documentation

postgresql Documentation

The PostgreSQL object-relational database system provides reliability and data integrity.

redis Documentation

Redis is the world’s fastest data platform for caching, vector search, and NoSQL databases.

geoipupdate Documentation

Use ghcr.io/maxmind/geoipupdate for new releases

Check the logs first

Nine times out of ten the logs tell you exactly what went wrong.

  • In Portainer, go to Containers, click the container, then Logs. Or run docker logs <container>
  • Exit codes help too: 137 means killed, usually out of memory. 126 or 127 means the command inside the image is broken.

Can't reach the Docker socket

Authentik talks to Docker through /var/run/docker.sock. If the logs show "permission denied while trying to connect to the Docker daemon socket", the app's user can't access it.

  • Check the socket exists on the host: ls -l /var/run/docker.sock
  • Run the container as root, or add the docker group's id to the container with group_add.

Image won't pull

Test the pull directly on the host: docker pull postgres:12-alpine

  • "manifest unknown" means the tag no longer exists.
  • "toomanyrequests" is the Docker Hub rate limit. Log in with docker login to raise it.
  • "no space left on device" means a full disk. Reclaim space with docker system prune

"exec format error"

This means the image was built for a different CPU architecture than your server.

  • Check yours with uname -m: x86_64 is amd64, aarch64 is arm64. Raspberry Pi and other ARM boards are the usual culprits.

Container keeps restarting

The unless-stopped restart policy relaunches the app after every crash, so the real error can scroll past.

  • Check the logs right after a restart, the last few lines before it died are the useful ones.
  • Get the exit code with docker inspect <container> --format '{{.State.ExitCode}}'
  • Still stuck? Redeploy once with the restart policy set to no so the failure stays visible.

Stack won't deploy

Compose stacks fail fast on small mistakes, and Portainer shows the reason just above the editor.

  • YAML only accepts spaces for indentation, a single tab breaks the whole file.
  • Relative volume paths like ./media often fail in Portainer because there's no working directory. Swap them for absolute paths.

Raise an issue

Found something which isn't working as it should? Here's how to report it.

A Compose stack

Authentik is a Compose stack, a set of containers (5 of them) defined in one file and brought up together by Portainer, then started and stopped as a single app.

The services

This stack is built from 5 containers that run side by side. Here's each one, with the image it runs and anything it waits for first:

  • postgresql runs postgres:12-alpine
  • redis runs redis:alpine
  • server runs ghcr.io/goauthentik/server:2021.12.5
  • worker runs ghcr.io/goauthentik/server:2021.12.5
  • geoipupdate runs maxmindinc/geoipupdate:latest

Volumes

A volume is where Authentik keeps its files so they survive an update or a restart. Without one, anything it saves would sit inside the container and vanish the moment it's recreated. This template mounts:

  • /var/lib/postgresql/data kept in the database volume Docker manages
  • /media from ./media on the host
  • /templates from ./custom-templates on the host
  • /geoip kept in the geoip volume Docker manages
  • /backups from ./backups on the host
  • /certs from ./certs on the host
  • /var/run/docker.sock from /var/run/docker.sock on the host (a socket it talks to, not storage)
  • /usr/share/GeoIP kept in the geoip volume Docker manages

Environment variables

Environment variables are the settings you hand over when you deploy, things like a password or a timezone. Authentik takes 10 of them, and one needs a value before it'll start properly:

  • POSTGRES_PASSWORD, needs a value
  • POSTGRES_USER, defaults to authentik
  • POSTGRES_DB, defaults to authentik
  • AUTHENTIK_REDIS__HOST, defaults to redis
  • AUTHENTIK_POSTGRESQL__HOST, defaults to postgresql
  • AUTHENTIK_POSTGRESQL__USER, defaults to authentik
  • AUTHENTIK_POSTGRESQL__NAME, defaults to authentik
  • AUTHENTIK_POSTGRESQL__PASSWORD, pulled from your own environment
  • GEOIPUPDATE_EDITION_IDS, defaults to GeoLite2-City
  • GEOIPUPDATE_FREQUENCY, defaults to 8

Restart policy

The restart policy here is unless-stopped, so Docker restarts Authentik after a crash or reboot, but leaves it off when you stop it on purpose. You can change this on the deploy screen. The choices are no (never restart), on-failure (only after a crash), unless-stopped (restart unless you stop it), and always (bring it back no matter what).

Networking

Portainer puts these services on one shared private network, so they can find each other by name (like postgresql) while only the ports above are open to you.

Platform

The platform is linux, the kind of system the container is built to run on. Docker and Portainer handle this on a normal Linux server.

Portainer app templates

Zooming out, this whole page comes from a Portainer app template: a short recipe telling Portainer how to set Authentik up. Add the template list to Portainer once, then deploying Authentik is a click rather than a wall of config.