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. ;)
Most helpful comment
You'll want to use exec inspect to get the status of an exec.