简体   繁体   中英

What's wrong with this docker-compose.yml file to start traefix, wordpress and mariadb containers?

I am trying to configure and start docker containers for traefik, wordpress using mariadb The error below is that traefik can't find the traefik.toml file. I supplied the yml file for you to review and offer suggested changes.

I've been composing this yml file from varios sources on the web. The wordpress container and maria db containers startup fine. Traefik is the problem. Though I'm not totally sure about 8081:80 for the wordpress. To run wordpress by itself without traefik it is 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

ERROR: for reverse-proxy Cannot create container for service reverse-proxy: lstat /var/lib/docker/overlay2/5c7a86d350dd0871cdb9cfc65bd329793edcc79c77a65386312c4aa6fc645022/merged/traefik/traefik.toml: not a directory ERROR: Encountered errors while bringing up the project.

This docker-compose.yml worked for me. Could I kindly ask you to check?

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: {}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM