0

I have an endpoint inside a docker container. When I call the endpoint from postman it works as intended. When I call it from node.fetch from another container it also works but when I call it from another docker container using chai, I get the following error:

curl: (7) Couldn't connect to server

The chai call works well, since I can see the correct logs. How ever when I get to the following line of code it doesn't behave as expected.

This is the chai code:

res = await chai
   .request(server)
   .post('/bot_manager/management/initiliaze')
   .set('content-type', 'application/json')
   .send(body)

This is the line where it fails:

exec(`curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -d '{ "Image": "strategy_baseline", "ExposedPorts": { "${PORT}/tcp": {} }, "HostConfig": { "Binds": ["utils:/usr/src/app/utils:delegated","${process.env.CURRENT_PATH}/src/bot_manager/api/strategies/${botId}.js:/usr/src/app/strategies/${botId}.js"], "NetworkMode": "goatFish_backend", "PortBindings": { "${PORT}/tcp": [{ "HostPort": "${PORT}" }]}}, "Env": ["BOTNAME=${botId}", "PORT=${PORT}", "PAIR=${PAIR}"]}' -X POST http:/v1.4/containers/create?name=${botId}`, (err, stdout, stderr) => {// empty}

This works well in every method except chai. I also use the exact sam input through out the different methods.

Any help or indications are much appreciated. TIA!!

lucas rodriguez
  • 980
  • 2
  • 8
  • 20
  • 1
    It seems like the there is no network connection to the docker container. That is a good starting point – MatzZze Jul 22 '20 at 20:55
  • hmmmh, in this case however, this endpoint is not running in a docker container, I create a temporary server with chai and then call the ednpoint from that server. I have connection to it, cause I get the logs that show a connection opening and closing after the failure and several other function execute. – lucas rodriguez Jul 22 '20 at 21:07
  • 1
    I suggest you install `tcpdump` if the docker container are unix images. With this tool you can see the network packets sent and possibly it helps tracking down the issue. – MatzZze Jul 22 '20 at 21:14

0 Answers0