7.1.0 • Published 1 month ago

@linzjs/docker-command v7.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

@linzjs/docker-command

Run a command in either docker or on you local system

import { Command } from '@linzjs/docker-command';

const cmd = new Command('echo', { container: 'ubuntu', tag: 'latest' });

// Spawn a docker container and run `echo hello world`
await cmd.create().arg('Hello World').run(); // {stdout: "Hello World\n"}
// Spawn a echo process and run `echo hello world`
await cmd.create({ useDocker: false }).arg('Hello World').run(); // {stdout: "Hello World\n"}

Mounting folders in docker

folders can be mounted into the docker container volumes with .mount

.mount(path) will create a single --volume path:path

import { Command } from '@linzjs/docker-command';

const proc = await Command.create('ls', { container: 'ubuntu' });
proc.mount('/home/blacha');
proc.arg('/home/blacha');

await proc.run(); // ls results for local /home/blacha

Passing environment variables

import { Command } from '@linzjs/docker-command';

const proc = await Command.create('env', { container: 'ubuntu' });
proc.env('AWS_ACCESS_KEY_ID'); // Load process.env.AWS_ACCESS_KEY_ID into docker
proc.env('AWS_ACCESS_KEY_ID', 'fakeKey'); // set a specific AWS_ACCESS_KEY_ID into docker
7.1.0

1 month ago

7.0.0

5 months ago

6.32.1

2 years ago

6.28.0

2 years ago

6.28.1

2 years ago

6.21.1

2 years ago

6.10.0

3 years ago

6.9.1

3 years ago

6.0.0

3 years ago

5.0.0

3 years ago

4.22.0

3 years ago

4.20.0

3 years ago