Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Todo app fails on startup with docker-compose #48

Closed
Terag opened this issue Jun 2, 2020 · 0 comments
Closed

Todo app fails on startup with docker-compose #48

Terag opened this issue Jun 2, 2020 · 0 comments

Comments

@Terag
Copy link
Contributor

@Terag Terag commented Jun 2, 2020

Current

In the getting started tutorial, we create the following docker-compose.yml to start the app with mysql:

version: "3.7"

services:
  app:
    image: node:12-alpine
    command: sh -c "yarn install && yarn run dev"
    ports:
      - 3000:3000
    working_dir: /app
    volumes: 
     - ./:/app
    environment:
      MYSQL_HOST: mysql
      MYSQL_USER: root
      MYSQL_PASSWORD: secret
      MYSQL_DB: todos
  mysql:
    image: mysql:5.7
    volumes:
      - todo-mysql-data:/var/lib/mysql
    environment: 
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: todos

volumes: 
  todo-mysql-data:

When running this with docker-compose up -f, the container for the todo application fails.

app_1    | Waiting for mysql:3306................
app_1    | Timeout
app_1    | Error: connect ECONNREFUSED 172.20.0.2:3306

To reproduce the error, run docker-compose up as specified in the tutorial. On some computer, the timeout of 15000ms is reached before the mysql container is fully initialized.

Suggestions

It seems that the app container does not wait long enough for the mysql container to be fully initialized as said in the documentation for mysql container:

If there is no database initialized when the container starts, then a default database will be created. While this is the expected behavior, this means that it will not accept incoming connections until such initialization completes. This may cause issues when using automation tools, such as docker-compose, which start several containers simultaneously.

The app container should wait long enough for the mysql container to be fully running and have a longer timeout or no timeout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant
You can’t perform that action at this time.