提问者:小点点

这个docker-compose.yml文件启动traefix、wordpress和mariadb容器有什么问题?


我正在尝试为 traefik 配置和启动 docker 容器,使用 mariadb 进行 wordpress 下面的错误是 traefik 找不到 traefik.toml 文件。我提供了 yml 文件供您查看并提供建议的更改。

我一直在从网络上的varios来源编写这个yml文件。wordpress容器和maria db容器启动正常。Traefik是问题所在。虽然我不完全确定 wordpress 的 8081:80。在没有traefik的情况下自行运行wordpress是80:80

version: '3'

services:
  reverse-proxy:
    image: traefik:1.7.2-alpine # The official Traefik docker image
    command: --api --docker # Enables the web UI and tells Traefik to listen to$
    ports:
      - "80:80"     # The HTTP port
      - "443:443"   # The HTTPS port
      - "8080:8080" # The Web UI (enabled by --api)
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen 
      - /traefik/traefik.toml
      - /traefik/acme.json:/acme.json
    networks:
      - web
  wordpress:
    image: wordpress
    links:
     - mariadb:mysql
    environment:
     - WORDPRESS_DB_PASSWORD=Mari1234_
    ports:
     - "152.44.45.150:8081:80"
    volumes:
     - ./html:/var/www/html
    networks:
      - web
  mariadb:
    image: mariadb
    environment:
     - MYSQL_ROOT_PASSWORD=Mari1234_
     - MYSQL_DATABASE=wordpress
    volumes:
     - ./database:/var/lib/mysql
    networks:
      - web
networks:
  internal:
  web:
    external: true

错误:对于反向代理,无法为服务反向代理创建容器:lstat/var/lib/docker/overlay2/5c7a86d350dd0871cdb9cfc65bd329793edcc79c77a6536312c4a6fc645022/memerged/traefik/traefik.toml:不是目录错误:启动项目时遇到错误。


共1个答案

匿名用户

这个docker-compose.yml为我工作。我可以请你检查一下吗?

version: '3.4'

services:
  web_traefik:
    image: traefik
    ports:
      - "80:80"
      - "8888:8080"
    command:
      - --docker
      - --docker.swarmMode
      - --docker.domain=docker.localhost
      - --docker.watch
      - --api
    deploy:
      placement:
        constraints:
          - node.role == manager
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - frontend-network

  wordpress:
    image: wordpress
    environment:
      - WORDPRESS_DB_USER=wordpress
      - WORDPRESS_DB_PASSWORD=wordpress
    deploy:
      replicas: 2
      labels:
        - traefik.port=80
        - traefik.docker.network=blog_frontend-network
        - traefik.backend.loadbalancer.sticky=true
        - traefik.backend.loadbalancer.stickiness=true
        - "traefik.frontend.rule=PathPrefix:/"
    networks:
      - frontend-network
      - backend-network

  mysql-seed:
    image: colinmollenhour/mariadb-galera-swarm
    deploy:
      endpoint_mode: dnsrr
    environment:
      - MYSQL_DATABASE=wordpress
      - MYSQL_USER=wordpress
      - MYSQL_PASSWORD=wordpress
      - XTRABACKUP_PASSWORD=wordpressbackup
    command:
      - seed
    networks:
      - backend-network

  mysql:
    image: colinmollenhour/mariadb-galera-swarm
    deploy:
      endpoint_mode: dnsrr
      replicas: 2
    environment:
      - XTRABACKUP_PASSWORD=wordpressbackup
    command:
      - node
      - tasks.mysql-seed,tasks.mysql
    networks:
      - backend-network


networks: 
  frontend-network: {}
  backend-network: {}