# docker-command-builder

> Docker command generator that take cares of container dependencies

Latest version **0.0.5** (published 2015-04-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install docker-command-builder
pnpm add docker-command-builder
yarn add docker-command-builder
bun add docker-command-builder
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2015-04-25 |
| First published | 2015-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Albert Lacarta |
| Maintainers | urodoz |
| Keywords | docker, command, builder, container, generator, docker-io |

## Links

- npm: https://www.npmjs.com/package/docker-command-builder
- Repository: https://github.com/urodoz/docker-command-builder
- Issues: https://github.com/urodoz/docker-command-builder/issues
- npm.io page: https://npm.io/package/docker-command-builder

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^3.7.0
- [mustache](https://npm.io/package/mustache.md) ^2.0.0
- [node-uuid](https://npm.io/package/node-uuid.md) ^1.4.3

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2015-04-25
- 0.0.4 — 2015-04-19
- 0.0.3 — 2015-04-18
- 0.0.2 — 2015-04-18

## README

# Docker Command Builder

Docker command generator that take cares of container dependencies

#### Build status

[![Build Status](https://travis-ci.org/urodoz/docker-command-builder.svg?branch=master)](https://travis-ci.org/urodoz/docker-command-builder)

## Installation

Use NPM to install the library:

```bash
npm install docker-command-builder
```
    
## Usage

You can use the runner component to create dependant containers:

```javascript
dockerComm = require("docker-command-builder");

var runnerBuilderChild = dockerComm("runner");
runnerBuilderChild
    .setName("selenium-named-chrome")
    .setImage("selenium-node-chrome:2.45.0")
    .setAlias("chrome")
    .setDaemon(true);
    
var runnerBuilder = dockerComm("runner");
    
runnerBuilder
    .setName("hub")
    .setImage("selenium-hub:2.45.0")
    .setDaemon(true)
    .addChild(runnerBuilderChild);
        
var runnerBuilderApp = dockerComm("runner");
    
runnerBuilderApp
    .setName("hub")
    .setImage("custom-application:1.0.0")
    .setDaemon(true)
    .addChild(runnerBuilder);
    
var command = runnerBuilderApp.make();
console.log(command)
```

Will output te next array :

    [
        'docker pull selenium-node-chrome:2.45.0',
        'docker pull selenium-hub:2.45.0',
        'docker pull custom-application:1.0.0',
        'docker run -d --name=selenium-named-chrome selenium-node-chrome:2.45.0',
        'docker run -d --name=hub --link selenium-named-chrome:chrome selenium-hub:2.45.0',
        'docker run -d --name=hub --link hub:selenium-hub custom-application:1.0.0'
    ]
    
You can set build folder and tag, environment variables, volumes, etc...

## Docker Version

You can initiate the any docker-commander object with different version, by default is the latest version.

```javascript
dockerComm = require("docker-command-builder");

var runnerBuilderChild_13 = dockerComm("runner", 1.3); //<-- set the version on creation
```

## API

### puller

Exposed by:

```javascript
require("docker-command-builder")("puller")
```

#### puller#setImage(image)

Sets the name of the image for the pull command

#### puller#setRegistry(registry)

By default is setted to null (the official docker registry), you can change it on this variable

```javascript
var pullerBuilder = dockerComm("puller");
pullerBuilder.setImage("image1");
pullerBuilder.setRegistry("registry.custom.server.com");
pullerBuilder.setVersion("1.1.1");
var command = pullerBuilder.make();

console.log(command);
//--> docker pull registry.custom.server.com/image1:1.1.1
```

#### puller#make

Generates the command array

### builder

Exposed by ```require("docker-command-builder")("builder")```

#### builder#setTag(tag)

Sets the tag of the build

#### builder#setDir(dir)

Sets the dir of the build. Must be absolute path

#### builder#make

Generates the command array

### runner

Exposed by ```require("docker-command-builder")("runner")```

#### runner#setBuild(tag,dir)

Disables the image option, and sets the build tag as image of the run

#### runner#setAlias(alias)

If setted, instead the name of the image to generate the link on parent containers, will use the alias

#### runner#getAlias

Returns the alias

#### runner#addPort

Add a port definition as ```127.0.0.1:8000:80```

#### runner#addChild(runner instance)

Add a runner instance as child container

#### runner#setDaemon(boolean flag)

Sets the run command as daemon or not (by default is ```true```). If enabled, disables the cleanUp flag.

#### runner#setCleanUp(boolean flag)

Sets the container flag for clean up (--rm). If enabled, disables the daemon flag.

#### runner#setPrivileged(boolean flag)

Sets the container flag for privileged container (--privileged).

#### runner#setImage(image)

Sets the image of the command. Disabled the build information.

#### runner#getImage

Returns the image setted.

#### runner#addEnvironmentVariable(key,value)

Adds a new environment variable to the container

#### runner#addVolume(hostDir,containerDir,mode=rw|ro[optional])

Adds a new volume to the container. Mode by default is empty

#### runner#make

Generates the command array

## TODO

* Add runtime constraints to runner (memory and cpu)
* Add user option to runner
* Add workdir option to runner
* Add command option to runner

## LICENSE 

MIT

---
_Source: https://npm.io/package/docker-command-builder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
