Home

Deploy portainer to server with traefik https (docker compose)

install portainer in localhost

visit https://portainer.io/install.html and do it :)))

deploy portainer to server remote

I use docker-compose to do it. We have docker-compose file:

version: '3.3'

networks:
  backend:
  proxy:
    external: true

volumes:
  portainer_traefik_data:
    external: true

configs:
  traefik-config:
    external: true

services:
  portainer:
    image: portainer/portainer
    ports:
    - "9000:9000"
    command: -H unix:///var/run/docker.sock
    networks:
      - proxy
    dns: 8.8.8.8
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - portainer_traefik_data:/data
    labels:
    - traefik.docker.network=proxy
    - traefik.enable=true
    - traefik.basic.frontend.rule=Host:portainer.kudosvn.com
    - traefik.basic.port=9000
    - traefik.basic.protocol=http

deploy traefik to server remote

user docker-compose file:

version: '3.3'

networks:
  backend:
  proxy:
    external: true

volumes:
  traefik-opt:

configs:
  traefik-config:
    external: true

services:
  #======================================================================
  traefik:
    image: traefik:alpine
    ports:
      - 80:80
      - 443:443
    networks:
      - proxy
    dns: 8.8.8.8
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /opt/traefik/acme.json:/acme.json
    configs:
      - source: traefik-config
        target: /traefik.toml

importants

traefik docker-compose file must have dns: 8.8.8.8 to get amce certificate ssl for domain.

And run command:

touch /opt/traefik/docker-compose.yml
touch /opt/traefik/acme.json && chmod 600 /opt/traefik/acme.json
touch /opt/traefik/traefik.toml
comments powered by Disqus