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


mysql node-js docker

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

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

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

Node.js Live | Node.js Docker Tutorial | Dockerizing Node.js App|Node.js Training|Edureka

🔥 Node.js Certification Training: https://www.edureka.co/nodejs-certification-training This Edureka video on 'Node.js Docker Tutorial' will help you in learn...

Node JS with Typescript TypeORM Mysql (Docker compose) #04

Full Playlist https://www.youtube.com/playlist?list=PLT5Jhb7lgSBNmwHVnjEY7uwTv9_lDV1_s GitHub - Node JS with Typescript Mysql https://github.com/tkssharma/Ty...

Node JS with Typescript TypeORM Mysql (Controller & Service ) #12

Full Playlist https://www.youtube.com/playlist?list=PLT5Jhb7lgSBNmwHVnjEY7uwTv9_lDV1_s GitHub - Node JS with Typescript Mysql https://github.com/tkssharma/Ty...

How to Hire Node.js Developers And How Much Does It Cost?

A Guide to Hire Node.js Developers who can help you create fast and efficient web applications. Also, know how much does it cost to hire Node.js Developers.

Node JS with Typescript TypeORM Mysql (Mysql DB Service ) #08

Full Playlist https://www.youtube.com/playlist?list=PLT5Jhb7lgSBNmwHVnjEY7uwTv9_lDV1_s GitHub - Node JS with Typescript Mysql https://github.com/tkssharma/Ty