NodeJS library to interact with the Docker engine.
JavaScript:
const Docker = require('lup-docker');
// List of all containers
const containers = await Docker.getContainers().then(result => result.success || []);
console.log(containers);
// Stream of a containers utilization stats
const statsStream = await Docker.getContainerStatsStream('busybox').then(result => result.success);
if(statsStream){
const statsReader = statsStream.getReader();
while(true){
const { done, value } = await statsReader.read();
if(done) break;
// Process the stats data
console.log(value);
}
}TypeScript:
import lupSystem from 'lup-docker';
// List of all containers
const containers = await Docker.getContainers().then(result => result.success || []);
console.log(containers);
// Stream of a containers utilization stats
const statsStream = await Docker.getContainerStatsStream('busybox').then(result => result.success);
if(statsStream){
const statsReader = statsStream.getReader();
while(true){
const { done, value } = await statsReader.read();
if(done) break;
// Process the stats data
console.log(value);
}
}