Dockerode: how would i know process.exit code when doing docker.exec?

Created on 17 Sep 2015  路  5Comments  路  Source: apocas/dockerode

question

Most helpful comment

You'll want to use exec inspect to get the status of an exec.

exec.inspect(function(err, data) {
  if (!err && !data.Running) {
    console.log('%s exited with code %d',
                data.ProcessConfig.entrypoint,
                data.ExitCode);
  }
});

All 5 comments

I'm trying to docker-exec to another container and my command fails. Somehow I need to know the process.exit or any error

Could you please provide an example with code?
People will help you a lot faster with something to debug :)

@apocas here's my code for docker exec

        let execOptions = {
            "AttachStdout" : true,
            "AttachStderr" : true,
            "Tty"                : false,
            "Cmd"             :  command
        };

        container.exec( execOptions, ( error, exec ) => {
            if ( error ) {
                return callback( error );
            }

            exec.start( ( errorStart, stream ) => {
                if ( errorStart ) {
                    return callback( errorStart );
                }

                stream.on( 'end', () => {
                    callback();
                } );

                stream.on( 'error', error => {
                    callback( error );
                } );

                stream.pipe( process.stdout );
            } );

        } );

while I can get the statusCode of stream but it's the http status request
my sample command would be npm test and my test sometimes fails. Do you have any idea on how I can know if my commands fails or not. Currently, my test will process.exit(1) if it fails
thanks! :)

You'll want to use exec inspect to get the status of an exec.

exec.inspect(function(err, data) {
  if (!err && !data.Running) {
    console.log('%s exited with code %d',
                data.ProcessConfig.entrypoint,
                data.ExitCode);
  }
});

@rmg thanks! works on my end. ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AlexanderCollins picture AlexanderCollins  路  5Comments

IniZio picture IniZio  路  3Comments

lakindu95 picture lakindu95  路  3Comments

controversial picture controversial  路  3Comments

knight42 picture knight42  路  6Comments