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!!