2019-09-19 16:07:12 +00:00
|
|
|
var express = require('express');
|
|
|
|
var router = express.Router();
|
2019-09-19 16:30:38 +00:00
|
|
|
var docker = require('../bin/dockerode');
|
2019-09-19 16:07:12 +00:00
|
|
|
|
|
|
|
|
2019-09-19 16:27:24 +00:00
|
|
|
|
2019-09-19 18:13:08 +00:00
|
|
|
router.get('/:id', (req, res, next) => {
|
|
|
|
getContainer(id).then(data => {
|
|
|
|
res.send(data);
|
|
|
|
});
|
2019-09-19 16:07:12 +00:00
|
|
|
});
|
|
|
|
|
2019-09-19 16:27:24 +00:00
|
|
|
|
|
|
|
function getContainer(containername) {
|
2019-09-19 18:13:08 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const container = docker.getContainer(containername);
|
|
|
|
container.inspect((err, data) => {
|
|
|
|
resolve({ err, data });
|
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = router;
|