Skip to content

Instantly share code, notes, and snippets.

@stepankuzmin
Created May 5, 2018 11:31
Show Gist options
  • Save stepankuzmin/4b71c657ef409d9b0b357d25e1dd74c9 to your computer and use it in GitHub Desktop.
Save stepankuzmin/4b71c657ef409d9b0b357d25e1dd74c9 to your computer and use it in GitHub Desktop.
Example docker usage from NodeJS
const request = require("request-promise");
const main = async () => {
try {
const { Id, Warnings } = await request({
method: 'POST',
uri: 'http://unix:/var/run/docker.sock:/v1.24/containers/create',
body: { Image: 'bfirsh/reticulate-splines' },
headers: {
'Host': null,
// 'Host': 'localhost',
'Content-Type': 'application/json'
},
json: true
});
if (Warnings) {
console.log('Warnings:', Warnings);
}
await request({
method: 'POST',
uri: `http://unix:/var/run/docker.sock:/v1.24/containers/${Id}/start`,
headers: {
'Host': null
}
});
console.log('Id', Id);
} catch (e) {
console.error(e);
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment