0.0.13 • Published 7 years ago

tsdocker v0.0.13

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

tsDocker

About

tsdocker is a typescript library heavily inspired by dockerode. The difference is that this library includes complete typing support and is written differently.

It's still a work in progress.

Current limitations

We have the following limitations

  • You can't attach to a container
  • You can't export or import images, container filesystem etc.
  • You currently can only connect to docker via the socket on windows/linux based on the socket path.
  • TLS connections are not yet supported.

All of the above will be implemented when the "missing implementations" are done :-)

Implemented

  • Container
  • Image
  • Network
  • Volume
  • Exec

Missing implementations

  • Swarm
  • Nodes
  • Services
  • Tasks
  • Secrets
  • Plugins
  • System
  • Get Task logs

Installation

To install tsdocker, run the following:

$ npm install tsdocker --save

When tsdocker is mature, it will follow the docker remote api versioning. This means if you want to target docker remote api v. 1.30

$ npm install tsdocker@1.30 --save

Usage

Example of how to download an image, create a container and use the exec to run apt-get update :-)

import { Readable } from 'stream';
import { DockerClient } from 'tsdocker';

const client = new DockerClient();

async function run() {
    const image = await client.images.create.execute({
        fromImage: 'ubuntu',
        tag: 'latest',
    });

    image.pipe(process.stdout);
    image.on('end', () => createContainer());
}

async function createContainer() {

    const container = await client.container.create.execute({
        Image: 'ubuntu:latest',
        Tty: true,
    });

    await client.container.start.execute(container.Id);
    const exec = await client.exec.create.execute({
        id: container.Id,
        exec: {
            attachStderr: true,
            attachStdout: true,
            tty: true,
            cmd: ['apt-get', 'update'],
        },
    });

    const runningExec = await client.exec.start.execute({
        id: exec.Id,
        Detach: false,
        Tty: true,
    }) as Readable;

    runningExec.on('data', (x) => process.stdout.write(x));
    runningExec.on('end', async () => await client.container.remove.execute(container.Id, {
        force: true,
    }));
}

run();

License

MIT © StormCi

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago