GithubHelp home page GithubHelp logo

docklift's Introduction

docklift v0.7.0 Circle CI codecov.io

Manage your docker containers from JavaScript

Install

npm install docklift

optionally (if you want to use es2015)

npm install babel-register babel-preset-es2015

How to use

First create docklift.babel.js file like the following:

import {task} from 'docklift'

task('start-my-container')
.create({
  name: 'my-container',
  image: 'ubuntu',
  cmd: 'some-command',
  ports: [process.env.MY_HOST_PORT + ':3000']
})
.do(container => {

  return container.start()

})

task('kill-my-container')
.get('my-container', {quiet: true})
.do(container => {

  return container.remove()

})

Then, invoke docklift command

./node_modules/.bin/docklift start-my-container

The above command automatically find the docklift.js and executes the command in it. In this case it starts the container of the given name.

./node_modules/.bin/docklift kill-my-container

The above kills and removes the container of the same name my-container-XXXX

API

import {task} from 'docklift'

task(taskName)

  • @param {string} taskName The task name to register
  • @return {TaskModifier}

Creates and registers a task of the given name. Returns task modifier and you can define your own container actions in the task.

task().create({name, image, cmd, ports}[, ...]).do(action)

  • @param {string} name The name of the container
  • @param {string} image The image of the container (necessary only when creating container)
  • @param {string} cmd The command
  • @param {string|string[]} ports The port forwarding settings
  • @param {Function} action The action to perform

Creates the container(s) and perform the action(s) on it.

task().get(names).do(action)

  • @param {string|string[]} names The names of the container to get
  • @param {Function} action The action to perform

Gets the container(s) and perform the action(s) on it.

Container class

container.start()

  • @return {Promise}

Starts the container.

container.stop()

  • @return {Promise}

Stops the container.

container.remove()

  • @return {Promise}

Removes the container.

License

MIT

Name

docklift is a tool which lifts up the ability of docker by its scripting capability.

docklift's People

Contributors

kt3k avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.