At present, I list all containers first and then filter out the one with the right name.
Got it. Sorry for the noise.
Would have been nice to see the solution.. ;) Just for reference this was my solution:
getContainerByName(name) {
// filter by name
var opts = {
"limit": 1,
"filters": `{"name": ["${name}"]}`
}
return new Promise((resolve, reject)=>{
this.dockerode.listContainers(opts, function(err, containers) {
if(err) {
reject(err)
} else{
resolve(containers && containers[0])
}
});
})
}
The passing the name value as an array tripped me up, so don't forget those.
@knight42 So, would you like to share your solution? I can still not find any hints in documents
@davidkhala Simply docker.getContainer(containerName) should work.
@knight42 Thanks, and I found that getContainer return only a memory-object without checking its existence. I use Container.inspect() to do that and test OK. Or any other recommend?
@knight42 does it works the same way with getService?