I get connection refused: Unable to connect when using unix socket -
let options = {
socketPath: '/var/run/docker.sock',
path: `/v1.43/containers/json`,
method: 'GET',
};
let clientRequest = http.request(options, (res) => {
res.setEncoding('utf8');
let rawData = '';
res.on('data', (chunk) => {
rawData += chunk;
});
res.on('end', () => {
const parsedData = JSON.parse(rawData);
console.log(parsedData);
});
});
clientRequest.on('error', (e) => {
console.log(e);
});
clientRequest.end();