Dockerode: How to use `log` api of container?

Created on 10 Mar 2017  路  2Comments  路  Source: apocas/dockerode

Get a 400 error while using container.log()
(HTTP code 400) unexpected - {"message":"Bad parameters: you must choose at least one stream"}

question

Most helpful comment

You can find available parameters here => https://docs.docker.com/engine/api/v1.19/#get-container-logs
At least this option object will give you back incoming data

var logOpts = {
     stdout: 1,
     stderr: 1,
     tail:100,
     follow:0
};
container.logs(logOpts, function(data, err) {
    data.setEncoding('utf8');
    data.on('data', function(data) {
        for(var i in data) {
            console.log(data[i]);
        }
    })
});

All 2 comments

You can find available parameters here => https://docs.docker.com/engine/api/v1.19/#get-container-logs
At least this option object will give you back incoming data

var logOpts = {
     stdout: 1,
     stderr: 1,
     tail:100,
     follow:0
};
container.logs(logOpts, function(data, err) {
    data.setEncoding('utf8');
    data.on('data', function(data) {
        for(var i in data) {
            console.log(data[i]);
        }
    })
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

yamii picture yamii  路  5Comments

jankeromnes picture jankeromnes  路  5Comments

florentvaldelievre picture florentvaldelievre  路  4Comments

stanleygu picture stanleygu  路  4Comments

peterpetre picture peterpetre  路  6Comments