Skip to content

Docker container management with Traefik v2 and Portainer

License

Notifications You must be signed in to change notification settings

dbartumeu/docker-traefik-portainer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker container management with Traefik v2 and Portainer

A configuration set-up for a Traefik v2 reverse proxy along with Portainer and Docker Compose.

This set-up makes container management & deployment a breeze and the reverse proxy allows for running multiple applications on one Docker host. Traefik will route all the incoming traffic to the appropriate docker containers and through the open-source app Portainer you can speed up software deployments, troubleshoot problems and simplify migrations.

Prerequisites

docker

apt update && apt upgrade
apt install apt-transport-https ca-certificates curl software-properties-common && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

Make sure we are installing it from docker:

apt-cache policy docker-ce
apt install docker-ce

Testing installation:

systemctl status docker

docker compose

curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose

How to run it?

I. Clone the repo

git clone https://github.com/dbartumeu/docker-traefik-portainer ./src && cd src/core

II. Create credentials

Make sure your server has htpasswd installed. If it doesn’t you can do so with the following command:

sudo apt-get install apache2-utils

Then run the below command, replacing the username and password with the one you want to use.

echo $(htpasswd -nb <username> <password>)

Edit the .env file and add your auth string to TRAEFIC_AUTH. Also replace ACME_EMAIL, TRAEFIC_HOST and PORTAINER_HOST with your own values.

source .env

III. Create the proxy network

docker network create proxy

IV. Give the proper permissions to acme.json

sudo chmod 600 ./traefik-data/acme.json

V. Run the stack

sudo docker-compose up -d

Adding services

Using Create stack in portainer copy and paste the dockerfile and make sure to include in the dockerfile:

services:
    ...
    networks:
      - proxy
      - default
    labels:
        - "traefik.enable=true"
        - "traefik.docker.network=proxy"
        - "traefik.http.routers.myservice.entrypoints=websecure"
        - "traefik.http.routers.myservice.rule=Host(`myservice.yourdomain.com`)"
        - "traefik.http.services.myservice.loadBalancer.server.port=myserviceport"

networks:
  proxy:
    external: true
  default:

Make sure to change myservice, myservice.yourdomain.com and myserviceport for meaningful values.

About

Docker container management with Traefik v2 and Portainer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%