I'm a complete docker noob. Just installed docker and docker-compose as well as portainer following a tutorial.
Now I would like to set up traefik reverse proxy on portainer.
This is the traefik.yml file in /etc/traefik
global:
checkNewVersion: true
sendAnonymousUsage: false # true by default
# (Optional) Log information
# ---
# log:
# level: ERROR # DEBUG, INFO, WARNING, ERROR, CRITICAL
# format: common # common, json, logfmt
# filePath: /var/log/traefik/traefik.log
# (Optional) Accesslog
# ---
# accesslog:
# format: common # common, json, logfmt
# filePath: /var/log/traefik/access.log
# (Optional) Enable API and Dashboard
# ---
api:
dashboard: true # true by default
insecure: true # Don't do this in production!
# Entry Points configuration
# ---
entryPoints:
web:
address: :80
# (Optional) Redirect to HTTPS
# ---
# http:
# redirections:
# entryPoint:
# to: websecure
# scheme: https
websecure:
address: :443
# Certificates configuration
# ---
# TODO: Custmoize your Cert Resolvers and Domain settings
#
This is the docker-compose file:
version: '3'
volumes:
traefik-ssl-certs:
driver: local
services:
traefik:
image: "traefik:v2.5"
container_name: "traefik"
ports:
- "80:80"
- "443:443"
# (Optional) Expose Dashboard
- "8080:8080" # Don't do this in production!
volumes:
- /etc/traefik:/etc/traefik
- traefik-ssl-certs:/ssl-certs
- /var/run/docker.sock:/var/run/docker.sock:ro
But when I try to start the container I get this error:
2021/12/08 18:08:07 command traefik error: yaml: line 19: did not find expected key
I can get the container to run when I remove the whole "volumes" section under "services" from the docker-compose file, but I need it for my traefik set up. I have no clue what I did wrong as I am following a video tutorial for this 1:1
CodePudding user response:
can you share the whole terminal log? Is that error from inside the container?
Anyhow, I think you should check your traefik.yml indentation. There are some keys at different levels and YAML is pretty sensible to this. I'm talking specially about:
- global
- checkNewVersion
- sendAnonymousUsage
- api
Check the number of spaces before them.
CodePudding user response:
Try putting double-quotes around the definition of the final volume (and the others too for consistency). eg:
version: '3'
volumes:
traefik-ssl-certs:
driver: local
services:
traefik:
image: "traefik:v2.5"
container_name: "traefik"
ports:
- "80:80"
- "443:443"
# (Optional) Expose Dashboard
- "8080:8080" # Don't do this in production!
volumes:
- "/etc/traefik:/etc/traefik"
- "traefik-ssl-certs:/ssl-certs"
- "/var/run/docker.sock:/var/run/docker.sock:ro"