Skip to main content

Install Portainer+Traefik stack

This installation is very easy. To make it simple we will install all that is related to this tutorial to you current user's home folder.

Let's create folders for Portainer and Traefik:

mkdir -p ~/pts/letsencrypt

Run the following commands to download docker-compose yaml with Portainer and Traefik with one of the following commands:

wget -O ~/pts/docker-compose.yaml "https://raw.githubusercontent.com/far4599/docker-portainer-traefik-stack/main/docker-compose.yaml"

Personalize your setup

Then we need to replace some variables in this file with your own values.

The first is a domain that you will use to access Portainer. Change portainer.example.com with your own domain or subdomain name and run this command.

export PORTAINER_DOMAIN="portainer.example.com"
sed -i "s/\${DOMAIN}/$PORTAINER_DOMAIN/g" ~/pts/docker-compose.yaml

Second is your email to be used for getting free ssl certificates for your domain. SSL certificates are issued by Let's Encrypt company, you email will be used to notify about certificates expiration. Replace [email protected] with your email and run this command.

export LETS_ENCRYPT_EMAIL="[email protected]"
sed -i "s/\${EMAIL}/$LETS_ENCRYPT_EMAIL/g" ~/pts/docker-compose.yaml

Network setup

By default running containers in Docker are isolated from each other. We need to create a global network to let Traefik communicate with other containers.

docker network create traefik

Run Portainer+Traefik stack

Run the following command to start the Portainer+Traefik stack:

cd ~/pts
docker compose up -d

This command will download all the required containers and start the stack. Wait until it is finished.