0

I am newbie on docker.

I want to migrate my nodejs app to docker, and existing database already installed on server (172.17.2.1). I set mariadb host 172.17.2.1 on my nodejs config. After that, I created an images and run with :

docker run -p 3009:3009 -d my-node

actually its already running, but when I tested to open by browser, I got an error that my app cannot connect to 172.17.2.1 (connecting to database).

I try to create bridge IP (172.17.2.135) and make a same subnet, but still got a same error. My images on docker inside doesn't know 172.17.2.1 on my LAN.

Please help me, I use windows 10 environment

1 Answers1

0

You have two options to allow your container to reach an external server:

  1. Run your docker container on your host network:

    docker run -p 3009:3009 --network host -d my-node

This way your container will be able to reach anything reachable from your machine

  1. create a network bridge: in this case docker will route the traffic from the container to the external server. the bridge IP can't be your docker machine IP as you tried to do.
Bouzid Zitouni
  • 1,119
  • 8
  • 12
  • hi, thx for reply, actually I already try both solutions above, but still same results, my app cannot access mariadb machine ip – Erwin Antonius Dec 04 '19 at 04:15