Getting no match url error when I use docker engine api for create an image in node js

Viewed 15

How can I set the param when I use the docker engine API? Here I add code that I have written. option for giving param for HTTP requests.

const option={
'cc':{
    socketPath: '//./pipe/docker_engine', //socket path for windows
    method: 'POST',
    path: `/containers/create`, 
    headers: {
      'content-type': 'application/json', 
    },
    data: {
      Image: "sampleappp"
    },
  },
}

//function where we passed the option and created the image 

function createImage(){
  let data = '';
 //Http request with the given option
  const apiReq = http.request(options.cb, (apiRes) => {
    apiRes.on('data', d => {
      data += d.toString();
    });
    apiRes.on('end', () => {
      console.log(`${apiRes.statusCode} - ${options.cb.path}`); //print the address and status 
      console.log(JSON.stringify(data, null, 2));
    });
  });
  apiReq.on('error', err => {
    console.log(err);
  });
  apiReq.end();
}
0 Answers
Related