Docker撰写healthcheck mysql

时间:2018-02-01 19:50:11

标签: mysql docker docker-compose

我正在使用以下设置: 1. Docker引擎:18.02.0-ce-rc1, 2.撰写1.18.0, 3. Mac

  mysql:
    image: mysql:5.6
    container_name: app-db
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    healthcheck:
      test: /usr/bin/mysql --host=127.0.0.1 --user=user --password=password --silent --execute \"SELECT 1;\"
      interval: 30s
      timeout: 10s
      retries: 5
    ports:
      - "3306:3306"
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - app
    restart: always

但是我总是很快得到以下错误(几秒钟内)

docker-compose up
Creating network "compose_app" with the default driver
Creating app-db ... done
Creating app-db ... 

ERROR: for app  Container "bf94292aa4fa" is unhealthy.
ERROR: Encountered errors while bringing up the project.

请帮忙。 感谢

0 个答案:

没有答案