2

I have created a nodeJs app container. The node app works fine, but I have difficulties in connecting it with the database that runs on host machine. This is my docker-compose configurations.

version: "3.0"
services:
 web:
  image: hello-world
  environment:
   DB_USER: someusername
   DB_PASSWORD: somepassword
   DB_HOST: 127.0.0.1
   DB_NAME: somedatabasename

Upon Running docker-compose up. The node app runs successfully, but whenever some database specific thing is performed, it returns with Econ refused error. I think that's because the docker looks at that DB_HOST and accesses the service from within container. What should I do with the DB_HOST so that my node app can access the db from outside the container?

Ijaz Khan
  • 41
  • 1
  • 4
  • https://stackoverflow.com/questions/22944631/how-to-get-the-ip-address-of-the-docker-host-from-inside-a-docker-container – Molda Feb 22 '19 at 14:28
  • Possible duplicate of [From inside of a Docker container, how do I connect to the localhost of the machine?](https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach) – David Maze Feb 22 '19 at 14:41

0 Answers0