0.0.0 • Published 10 years ago

dockerctl v0.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

Docker Controller

This is a small CLI app to make using Docker inside of projects a little easier. I hacked it together in a few spare hours on a Sunday so it's very rough around the edges.

The idea is you install this as a global npm module and then have a docker.json file inside of your project root which describes your images and containers like this:

{
  "directory": "docker/",
  "images": {
    "mgarratt/data": "data/",
    "mgarratt/nginx": "nginx/",
    "mgarratt/php-fpm": "php-fpm/"
  },
  "containers": {
    "data": {
      "name": "data",
      "image": "mgarratt/data",
      "volume": {
        ".": "/data/www:rw",
        "./docker/logs": "/data/logs:rw"
      },
      "detach": true,
      "privileged": true
    },
    "php-fpm": {
      "name": "php-fpm",
      "image": "mgarratt/php-fpm",
      "volumes-from": "data",
      "detach": true,
      "privileged": true
    },
    "nginx": {
      "name": "nginx",
      "image": "mgarratt/nginx",
      "volumes-from": "data",
      "link": "php-fpm:php-fpm",
      "publish": "80:80",
      "detach": true,
      "privileged": true
    }
  }
}

Images are simply named and given a path inside of the main directory, these relative paths are made absolute for use by Docker. Containers are given a name and the options to pass to them when running, things like volumes are converted to absolute paths relative to the cwd, not the directory set in the json file.

The following commands are available:

  • build - create all the images
  • run - run all the containers
  • stop - stop all the containers
  • rm - remove all the containers
  • rmi - remove all the images

Future ideas

In future I will add support for more Docker commands along with being able to enact the command on a single image or container.

Other ideas include things like getting the status of containers and varying useful information such as IP address and ports.