Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example do not work #68

Open
twodayslate opened this issue Mar 11, 2020 · 1 comment
Open

Example do not work #68

twodayslate opened this issue Mar 11, 2020 · 1 comment

Comments

@twodayslate
Copy link

twodayslate commented Mar 11, 2020

For example if I run

'use strict';
const {Docker} = require('node-docker-api');

const promisifyStream = stream => new Promise((resolve, reject) => {
  stream.on('data', data => console.log(data.toString()))
  stream.on('end', resolve)
  stream.on('error', reject)
});

const docker = new Docker({ socketPath: '/var/run/docker.sock' });
let _container;

docker.container.create({
  Image: 'ubuntu',
  Cmd: [ '/bin/bash', '-c', 'tail -f /var/log/dmesg' ],
  name: 'test'
})
  .then(container => container.start())
  .then(container => {
    _container = container
    return container.exec.create({
      AttachStdout: true,
      AttachStderr: true,
      Cmd: [ 'echo', 'test' ]
    })
  })
  .then(exec => {
    return exec.start({ Detach: false })
  })
  .then(stream => promisifyStream(stream))
  .then(() => _container.kill())
  .catch(error => console.log(error));

I get the following:

% uname -a
Darwin ME 19.3.0 Darwin Kernel Version 19.3.0: Thu Jan  9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64 x86_64
% node --version
v12.8.0
% node test.js
)cannot exec in a stopped state: unknown
@EgorBochkarev
Copy link

the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants