version: '3' services: # https://github.com/Tecnativa/docker-socket-proxy socket-proxy-traefik: networks: socket-proxy-traefik: restart: always image: tecnativa/docker-socket-proxy container_name: socket-proxy-traefik ports: - 127.0.0.1:2375:2375 environment: INFO: 1 CONTAINERS: 1 BUILD: 0 COMMIT: 0 CONFIGS: 0 DISTRIBUTION: 0 EXEC: 0 GRPC: 0 IMAGES: 0 NETWORKS: 0 NODES: 0 PLUGINS: 0 SERVICES: 0 SESSION: 0 SWARM: 0 SYSTEM: 0 TASKS: 0 VOLUMES: 0 volumes: - /var/run/docker.sock:/var/run/docker.sock:ro traefik: image: traefik:latest container_name: traefik restart: unless-stopped security_opt: - no-new-privileges:true networks: proxy: socket-proxy-traefik: ports: - 80:80 - 81:81 # external http - 443:443 - 444:444 # external https environment: - CF_API_EMAIL=your@email.com - CF_DNS_API_TOKEN=super-secure-token # - CF_API_KEY=YOU_API_KEY # be sure to use the correct one depending on if you are using a token or key volumes: - /etc/localtime:/etc/localtime:ro # - /var/run/docker.sock:/var/run/docker.sock:ro # use the socket-proxy - /home/ubuntu/docker/traefik/traefik.yml:/traefik.yml:ro - /home/ubuntu/docker/traefik/acme.json:/acme.json - /home/ubuntu/docker/traefik/config.yml:/config.yml:ro - /home/ubuntu/docker/traefik/logs:/var/log/traefik labels: - "traefik.enable=true" - "traefik.http.routers.traefik.entrypoints=http" # restricts dashboard to internal entrypoint - "traefik.http.routers.traefik.rule=Host(`traefik-docker.yourdomain.com`)" - "traefik.http.middlewares.traefik-auth.basicauth.users=admin:password-hash" - "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https" - "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https" - "traefik.http.routers.traefik.middlewares=traefik-https-redirect" - "traefik.http.routers.traefik-secure.entrypoints=https" - "traefik.http.routers.traefik-secure.rule=Host(`traefik-docker.yourdomain.com`)" - "traefik.http.routers.traefik-secure.middlewares=traefik-auth" - "traefik.http.routers.traefik-secure.tls=true" - "traefik.http.routers.traefik-secure.tls.certresolver=cloudflare" - "traefik.http.routers.traefik-secure.tls.domains[0].main=yourdomain.co.uk" - "traefik.http.routers.traefik-secure.tls.domains[0].sans=*.yourdomain.co.uk" - "traefik.http.routers.traefik-secure.service=api@internal" networks: proxy: external: true