I am trying to connect From Node.js on Localhost to MySQL instance running on docker using docker-compose. Node.js gives me this error: ENOTFOUND db, Full error message bellow. Here is docker-compose.yml that contains MySQL and adminer services. Here is my node.js database connection config. Answer You don’t tell us, but I assume your Node app is running on the host
Tag: docker-compose
How to send json messages between Node.js services inside a docker compose
Let’s say I have two Node.js services running inside a docker compose. Service A listens to port 4000 and service B listens to port 5000. How can I send a json message from service A to B (and vice versa) (by using Express)? Answer With a simple docker-compose file, the two services can access each other using their service name.
Sharing the `node_modules` folder between the container and the host
This is a pretty hot topic, but I’ve never actually found a solution. As you probably know, when we have a volume in a container and we install the dependencies (with npm i or something) from a Dockerfile (with default perms), Npm will create a node_modules folder in the container with root:root access. I’m facing two issues with this method