I get always an error 400 when I try to connect to docker api. When I try it with curl I get an response.
const request = require('request');
request('http://unix:/var/run/docker.sock:/v1.37/info', (error, response, body) => {
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log(body);
});
root@e014aa4c09ad:/docker-api# node test.js
error: null
statusCode: 400
400 Bad Request: malformed Host header
According to https://github.com/request/request/issues/2327#issuecomment-298317737, you need to set the
Host
header to null.