open-eats / OpenEats

:pizza: Self Hosted Recipe Management App :hamburger:
https://open-eats.github.io/
MIT License
670 stars 102 forks source link

Can't connect to MySQL after restarting config #101

Open SMeatBoy opened 5 years ago

SMeatBoy commented 5 years ago

I am trying to configure OpenEats to work with my existing docker containers. I therefore created my own docker-compose.yml in which I consolidated the parameters from the various compose files. Starting the containers for the first time or more than ~1 hour after reproducing this issue works without problems.

The issue arises when I try to recreate the containers after stopping and removing them together with their volumes. The API can't connect to the database: django.db.utils.OperationalError: (2003, 'Can\'t connect to MySQL server on \'db\' (111 "Connection refused")') This issue only occurs on my server running Debian stretch and Docker version 19.03.2, build 6a30dfca03. I was unsuccessful in reproducing this behaviour on my PC running Ubuntu 19.04 and Docker version 18.09.7, build 2d0083d.

My docker-compose.yml:

version: '2.3'
services:
  api:
    image: openeats/openeats-api:latest
    command: /startup/prod-entrypoint.sh
    depends_on:
      db:
        condition: service_healthy
    env_file:
      - openeats.env
    restart: always
    volumes:
      - static-files:/code/static-files
      - site-media:/code/site-media

  web:
    image: openeats/openeats-web
    command: yarn start
    depends_on:
      - api
    env_file:
      - openeats.env
    restart: on-failure
    volumes:
      - public-ui:/code/build

  db:
    image: mariadb
    env_file:
      - openeats.env
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
      timeout: 20s
      retries: 20
    volumes:
      - database:/var/lib/mysql
    restart: always

  nginx:
    build: ./openeats_nginx
    depends_on:
      - api
      - web
    ports:
      - 8000:80
    restart: always
    volumes:
      - static-files:/var/www/html/openeats-static/static-files
      - site-media:/var/www/html/openeats-static/site-media
      - public-ui:/var/www/html/openeats-static/public-ui

volumes:
  database:
  public-ui:
  static-files:
  site-media: