我正在尝试在Meteor应用程序上显示我在Docker中运行的所有容器和所有已停止的容器。目前我只能在停止运行容器时自动显示正在运行的容器。
我的代码中有容器(我需要帮助才能获得已停止的容器):
infosContainers.initContainers': function() {
/* create Docker object */
docker = new Docker({socketPath: '/var/run/docker.sock'});
/* create 2 var that are my containers running in docker */
meteorCtn = docker.getContainer('vialfeedmaclecturearticle_app_1');
mongoCtn = docker.getContainer('vialfeedmaclecturearticle_mongo_1');
/* I don't really understand but it's on the Dockerode page */
meteorCtn.defaultOptions.start.Binds = ["/tmp:/tmp:rw"];
mongoCtn.defaultOptions.start.Binds = ["/tmp:/tmp:rw"];
/* Add the id in the collection */
docker.listContainers(Meteor.bindEnvironment(function (err, containers) {
containers.forEach(function (containerInfo) {
InfosContainers.insert({
idContainer: containerInfo.Id,
nameContainer: containerInfo.Names[0],
stateContainer: containerInfo.State
});
});
}));
},
有人已经这样做了吗?谢谢你的帮助
答案 0 :(得分:0)
一如既往,当你要求找到......所以有解决方案
docker.listContainers({all: true}, function(err, containers) {
console.log('ALL: ' + containers.length);
});