How to use the dockerode.Container function in dockerode

To help you get started, we’ve selected a few dockerode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lando / lando / test / docker.spec.js View on Github external
it('should throw an error on all other catches', () => {
      // Our own little bad container.
      const bogusContainer = new Dockerode.Container();
      // Throw the proper error.
      const inspectStub = sinon.stub(bogusContainer, 'inspect').rejects(new Error('It\'s a trap!'));
      // Make sure we return the proper failing container.
      const getStub = sinon.stub(landerode, 'getContainer').returns(bogusContainer);

      return landerode.isRunning('foo').should.be
      .rejectedWith('It\'s a trap!').then(() => {
        getStub.restore();
        inspectStub.restore();
      });
    });
  });
github lando / lando / test / docker.spec.js View on Github external
it('should return true if State.Running inspect data is true', () => {
      // Container to return from 'getContainer';;l
      const bogusContainer = new Dockerode.Container({}, 'YT-1300');
      // Force the state of the container to be running.
      const inspectStub = sinon.stub(bogusContainer, 'inspect').resolves({
        State: {
          Running: true,
        },
      });
      // Force the return of our container
      const getStub = sinon.stub(landerode, 'getContainer').returns(bogusContainer);

      return landerode.isRunning('YT-1300').should.eventually.be.true
      .then(() => {
        inspectStub.restore();
        getStub.restore();
      });
    });
github lando / lando / test / docker.spec.js View on Github external
const dummyContainer = (overrides = {}) => {
  return _.assign(
    new Dockerode.Container(),
    {
      Id: '8675309',
      app: 'Death Star',
      Labels: {
        'com.docker.compose.project': 'Death Star',
        'com.docker.compose.service': 'Exhaust Port',
        'com.docker.compose.container-number': 73,
        'com.docker.compose.oneoff': 'no',
        'io.lando.container': 'TRUE',
        'io.lando.src': '/tmp/.lando.yml',
        'io.lando.id': 'lando',
        'io.lando.service-container': 'no',
      },
    },
    overrides
  );