NodeJS could not connect to MYSQL inside Docker Container

NodeJS could not connect to MYSQL inside Docker Container

I've complied following docker-compose file, encounter error message.

I've complied following docker-compose file, encounter error message.

version: '3'
services:
  node:
    build: ./app
    env_file:
      - ./.env
    ports:
      - "3000:3000"
    networks:
    - my-bridge-network
    depends_on:
      - "${MYSQL_HOST}"
  db:
    image: mysql:8.0.14
    env_file:
      - ./.env
    networks:
    - my-bridge-network
networks:
  my-bridge-network:
    driver: bridge

Here is configuration file for mysql sequelize,

{
    "production": {
        "username": "root",
        "password": "ppshein123456",
        "database": "database_production",
        "host": "0.0.0.0",
        "dialect": "mysql",
        "logging": false
    }
}

and Here is Dockerfile for NodeJS app,

FROM node:9.10.1
ENV NODE_ENV=development
COPY ./ /var/www
WORKDIR /var/www/
RUN yarn install && yarn add sequelize-cli -g
EXPOSE 3000
CMD /bin/bash ./wait-for-it.sh 127.0.0.1:3306 -- npm run docker

then, finally I encountered following error message:

Loaded configuration file "config/config.json". Using environment "production". Sat, 26 Jan 2019 01:03:45 GMT sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more athttp://docs.sequelizejs.com/manual/tutorial/querying.html#operators at node_modules/sequelize/lib/sequelize.js:242:13
ERROR: connect ECONNREFUSED 0.0.0.0:3306


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Crafting multi-stage builds with Docker in Node.js

Learn how you can use a multi-stage Docker build for your Node.js application. Docker multi-stage builds enable us to create more complex build pipelines without having to resort to magic tricks.

How to Use Express.js, Node.js and MongoDB.js

In this post, I will show you how to use Express.js, Node.js and MongoDB.js. We will be creating a very simple Node application, that will allow users to input data that they want to store in a MongoDB database. It will also show all items that have been entered into the database.

Dockerizing a Node.js web application

In this article, we will see how to dockerize a Node.js application. Dockerizing a Node.js web application