Deploy mysql node.js web app into docker container

I am trying to dockerize a node.js web app that connects to a mysql database. Just started using docker. Can’t seem to find any definitive answers online on how to configure this. I understand I need to use a “docker-compose.yaml” file and utilize docker-compose. But not sure what info needs to be entered into the yaml file.

Both the node.js app and the mysql server are located on same machine.

Have tried to follow this tutorial to build and run the docker container image.

But fails with the following error.

throw err;

Error: Cannot find module ‘mysql’

I don’t quite understand if the app has to be dockerized using docker-compose due to mysql.

Docker has become a standard tool not only among DevOps and Infrastructure people but also for the daily work of any developer. This article is aimed at the Docker beginners, who want to get a fully working instance of a Node Express and MongoDB app up and running in a matter of seconds for daily work. Docker will help you spin up containers (which behave like Virtual Machines but are not that heavy) and run your app on it. It gives us the ability to port the container anywhere we want on any server we want, moving from local to production gets secure and less buggy as the environment of the container which is running the app does not change.

In this tutorial, we will see How To Setup Node Express and MongoDB in Docker from scratch.