Docker Community Forums

Share and learn in the Docker community.

Deploy mysql node.js web app into docker container


(Aronb) #1

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. https://nodejs.org/en/docs/guides/nodejs-docker-webapp/

But fails with the following error.

module.js:550
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.