ECONNREFUSED nodeJS with express inside docker container

后端 未结 1 1499
自闭症患者
自闭症患者 2021-01-07 22:53

I\'m building up a nodejs app which is running in the docker container...

This is the command I used to run the container...

sudo docker run -it --rm         


        
1条回答
  •  执笔经年
    2021-01-07 23:34

    Are you hosting your third party api inside a docker container on localhost? If yes then you need to make sure that third-party api docker container is sharing same network. See https://docs.docker.com/engine/userguide/networking/. I had same problem trying to access rest endpoint which i assumed will be resolved with local host since it is running on my docker inside container. Here is a sequence of steps which helped me resolved issue:

    1. Execute docker network ls to see how many bridge drivers you have. In my case i had 2 and containers where using different ones
    2. If you have multiple bridge drivers, make sure that you starting your containers which will be talking with each other using same bridge network docker run -d -t --network networkname --name containername
    3. Run docker network inspect networkname. You will see details of network with list of containers. Each container will have IPv4Address associated with it. Use value of these address to communicate instead of localhost or 127.0.0.1

    0 讨论(0)
提交回复
热议问题