我的docker-compose.yml无法建立mysql5.7容器

时间:2019-12-14 01:44:00

标签: docker docker-compose yaml mysql-5.7

我正在尝试使用docker-compose.yml为laravel构建docker容器。

我喜欢为mysql5.7建立数据库容器。 无法在连接的服务器上使用Mysql8。

有我的docker-compose.yml文件。

version: "3"
services:
  app:
    build:
      context: ./docker/php
      args:
        - TZ=${TZ}
    ports:
      - ${APP_PORT}:8000
    volumes:
      - ${PROJECT_PATH}:/work
      - ./docker/ash:/etc/profile.d
      - ./docker/php/psysh:/root/.config/psysh
      - ./logs:/var/log/php
      - ./docker/php/php.ini:/usr/local/etc/php/php.ini
    working_dir: /work
    environment:
      - DB_CONNECTION=mysql
      - DB_HOST=db
      - DB_DATABASE=${DB_NAME}
      - DB_USERNAME=${DB_USER}
      - DB_PASSWORD=${DB_PASS}
      - TZ=${TZ}
      - MAIL_HOST=${MAIL_HOST}
      - MAIL_PORT=${MAIL_PORT}
      - CACHE_DRIVER=redis
      - SESSION_DRIVER=redis
      - QUEUE_DRIVER=redis
      - REDIS_HOST=redis

  web:
    image: nginx:1.17-alpine
    depends_on:
      - app
    ports:
      - ${WEB_PORT}:80
    volumes:
      - ${PROJECT_PATH}:/work
      - ./logs:/var/log/nginx
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
    environment:
      - TZ=${TZ}

  db:
    image: mysql:5.7
    volumes:
      - db-store:/var/lib/mysql
      - ./logs:/var/log/mysql
      - ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
    environment:
      - MYSQL_DATABASE=${DB_NAME}
      - MYSQL_USER=${DB_USER}
      - MYSQL_PASSWORD=${DB_PASS}
      - MYSQL_ROOT_PASSWORD=${DB_PASS}
      - TZ=${TZ}
    ports:
      - ${DB_PORT}:3306

  db-testing:
    image: mysql:5.7
    volumes:
      - ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
    tmpfs:
      - /var/lib/mysql
      - /var/log/mysql
    environment:
      - MYSQL_DATABASE=${DB_NAME}
      - MYSQL_USER=${DB_USER}
      - MYSQL_PASSWORD=${DB_PASS}
      - MYSQL_ROOT_PASSWORD=${DB_PASS}
      - TZ=${TZ}
    ports:
      - ${DB_TESTING_PORT}:3306

  node:
    image: node:12.13-alpine
    tty: true
    volumes:
      - ${PROJECT_PATH}:/work
    working_dir: /work

  redis:
    image: redis:5.0-alpine
    volumes:
      - redis-store:/data

  mail:
    image: mailhog/mailhog
    ports:
      - ${MAILHOG_PORT}:8025

volumes:
  db-store:
  redis-store:

当我在终端中执行“ docker-compose build”时,已成功完成,但是db容器和db-testing容器的状态为“ EXIT:1”或“ EXIT:2”。 所以,你能教我怎么了。

0 个答案:

没有答案