|
| 1 | +# dockops [](http://travis-ci.org/technote-space/dockops) |
| 2 | + |
| 3 | +docker convenience functions on top of dockerode |
| 4 | + |
| 5 | +<!-- START doctoc generated TOC please keep comment here to allow auto update param::entryPrefix::-:: --> |
| 6 | +<!-- param::mode::github.com:: --> |
| 7 | +<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> |
| 8 | +<!-- param::isNotitle::false:: param::maxHeaderLevel::8:: --> |
| 9 | +**Table of Contents** *generated with [DocToc](https://github.com/technote-space/doctoc)* |
| 10 | + |
| 11 | +- [Installation](#installation) |
| 12 | +- [API](#api) |
| 13 | +- [License](#license) |
| 14 | + |
| 15 | +<!-- END doctoc generated TOC please keep comment here to allow auto update --> |
| 16 | + |
| 17 | +```js |
| 18 | +var dockops = require('dockops') |
| 19 | +var docker = dockops.createDocker({ dockerhost: dockerhost }); |
| 20 | + |
| 21 | +var images = new dockops.Images(docker); |
| 22 | +dockops.logEvents(images, 'verbose'); |
| 23 | + |
| 24 | +var containers = new dockops.Containers(docker); |
| 25 | +dockops.logEvents(containers, 'verbose'); |
| 26 | + |
| 27 | +build('test:uno', testUnoTar, function () { |
| 28 | + build('toast:uno', toastUnoTar, function () { |
| 29 | + |
| 30 | + containers.run(.. // run test:uno and toast:uno containers |
| 31 | + |
| 32 | + containers.listRunning(function (err, res) { |
| 33 | + inspect(res); |
| 34 | + containers.stopRemoveGroup('test', function (err, res) { |
| 35 | + containers.listRunning(function (err, res) { |
| 36 | + inspect(res); |
| 37 | + http.request({ port: 49222 }, function (res) { |
| 38 | + console.log('--------------------------') |
| 39 | + inspect({ status: res.statusCode, headers: res.headers }) |
| 40 | + res.pipe(process.stdout) |
| 41 | + }).end() |
| 42 | + }) |
| 43 | + }) |
| 44 | + }) |
| 45 | + }) |
| 46 | +}) |
| 47 | +``` |
| 48 | +
|
| 49 | +[full example](https://github.com/technote-space/dockops/blob/master/example/create-wipe.js) |
| 50 | +
|
| 51 | + |
| 52 | +
|
| 53 | +## Installation |
| 54 | +
|
| 55 | + npm install dockops |
| 56 | +
|
| 57 | +## API |
| 58 | +
|
| 59 | +<!-- START docme generated API please keep comment here to allow auto update --> |
| 60 | +<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN docme TO UPDATE --> |
| 61 | +
|
| 62 | +<div> |
| 63 | +<div class="jsdoc-githubify"> |
| 64 | +<section> |
| 65 | +<article> |
| 66 | +<div class="container-overview"> |
| 67 | +<dl class="details"> |
| 68 | +</dl> |
| 69 | +</div> |
| 70 | +<dl> |
| 71 | +<dt> |
| 72 | +<h4 class="name" id="dockops::Containers"><span class="type-signature"></span>dockops::Containers<span class="signature">(docker)</span><span class="type-signature"> → {Object}</span></h4> |
| 73 | +</dt> |
| 74 | +<dd> |
| 75 | +<div class="description"> |
| 76 | +<p>Creates a new containers instance that will use the given docker instance to communicate with docker.</p> |
| 77 | +</div> |
| 78 | +<h5>Parameters:</h5> |
| 79 | +<table class="params"> |
| 80 | +<thead> |
| 81 | +<tr> |
| 82 | +<th>Name</th> |
| 83 | +<th>Type</th> |
| 84 | +<th class="last">Description</th> |
| 85 | +</tr> |
| 86 | +</thead> |
| 87 | +<tbody> |
| 88 | +<tr> |
| 89 | +<td class="name"><code>docker</code></td> |
| 90 | +<td class="type"> |
| 91 | +<span class="param-type">Object</span> |
| 92 | +</td> |
| 93 | +<td class="description last"><p>dockerode instance to communicate with docker</p></td> |
| 94 | +</tr> |
| 95 | +</tbody> |
| 96 | +</table> |
| 97 | +<dl class="details"> |
| 98 | +<dt class="tag-source">Source:</dt> |
| 99 | +<dd class="tag-source"><ul class="dummy"> |
| 100 | +<li> |
| 101 | +<a href="https://github.com/technote-space/dockops/blob/master/containers.js">containers.js</a> |
| 102 | +<span>, </span> |
| 103 | +<a href="https://github.com/technote-space/dockops/blob/master/containers.js#L24">lineno 24</a> |
| 104 | +</li> |
| 105 | +</ul></dd> |
| 106 | +</dl> |
| 107 | +<h5>Returns:</h5> |
| 108 | +<div class="param-desc"> |
| 109 | +<p>initialized containers</p> |
| 110 | +</div> |
| 111 | +<dl> |
| 112 | +<dt> |
| 113 | +Type |
| 114 | +</dt> |
| 115 | +<dd> |
| 116 | +<span class="param-type">Object</span> |
| 117 | +</dd> |
| 118 | +</dl> |
| 119 | +</dd> |
| 120 | +<dt> |
| 121 | +<h4 class="name" id="dockops::Containers::activePorts"><span class="type-signature"></span>dockops::Containers::activePorts<span class="signature">(cb)</span><span class="type-signature"></span></h4> |
| 122 | +</dt> |
| 123 | +<dd> |
| 124 | +<div class="description"> |
| 125 | +<p>Lists all running containers by the ports they expose.</p> |
| 126 | +</div> |
| 127 | +<h5>Parameters:</h5> |
| 128 | +<table class="params"> |
| 129 | +<thead> |
| 130 | +<tr> |
| 131 | +<th>Name</th> |
| 132 | +<th>Type</th> |
| 133 | +<th class="last">Description</th> |
| 134 | +</tr> |
| 135 | +</thead> |
| 136 | +<tbody> |
| 137 | +<tr> |
| 138 | +<td class="name"><code>cb</code></td> |
| 139 | +<td class="type"> |
| 140 | +<span class="param-type">function</span> |
| 141 | +</td> |
| 142 | +<td class="description last"><p>called back with list of containers hashed by their port number</p></td> |
| 143 | +</tr> |
| 144 | +</tbody> |
| 145 | +</table> |
| 146 | +<dl class="details"> |
| 147 | +<dt class="tag-source">Source:</dt> |
| 148 | +<dd class="tag-source"><ul class="dummy"> |
| 149 | +<li> |
| 150 | +<a href="https://github.com/technote-space/dockops/blob/master/containers.js">containers.js</a> |
| 151 | +<span>, </span> |
| 152 | +<a href="https://github.com/technote-space/dockops/blob/master/containers.js#L275">lineno 275</a> |
| 153 | +</li> |
| 154 | +</ul></dd> |
| 155 | +</dl> |
| 156 | +</dd> |
| 157 | +<dt> |
| 158 | +<h4 class="name" id="dockops::Containers::clean"><span class="type-signature"></span>dockops::Containers::clean<span class="signature">(id, cb)</span><span class="type-signature"></span></h4> |
| 159 | +</dt> |
| 160 | +<dd> |
| 161 | +<div class="description"> |
| 162 | +<p>Stops and/or kills and then removes a container.</p> |
| 163 | +<p>Heavy machinery clean operation. |
| 164 | +It was useful when running on arch with docker not always working as promised. |
| 165 | +This may not be needed anymore as docker got more stable.</p> |
| 166 | +</div> |
| 167 | +<h5>Parameters:</h5> |
| 168 | +<table class="params"> |
| 169 | +<thead> |
| 170 | +<tr> |
| 171 | +<th>Name</th> |
| 172 | +<th>Type</th> |
| 173 | +<th class="last">Description</th> |
| 174 | +</tr> |
| 175 | +</thead> |
| 176 | +<tbody> |
| 177 | +<tr> |
| 178 | +<td class="name"><code>id</code></td> |
| 179 | +<td class="type"> |
| 180 | +<span class="param-type">string</span> |
| 181 | +</td> |
| 182 | +<td class="description last"><p>container id</p></td> |
| 183 | +</tr> |
| 184 | +<tr> |
| 185 | +<td class="name"><code>cb</code></td> |
| 186 | +<td class="type"> |
| 187 | +<span class="param-type">function</span> |
| 188 | +</td> |
| 189 | +<td class="description last"><p>called back after container was cleaned or maximum attempts were exceeded</p></td> |
| 190 | +</tr> |
| 191 | +</tbody> |
| 192 | +</table> |
| 193 | +<dl class="details"> |
| 194 | +<dt class="tag-source">Source:</dt> |
| 195 | +<dd class="tag-source"><ul class="dummy"> |
| 196 | +<li> |
| 197 | +<a href="https://github.com/technote-space/dockops/blob/master/containers.js">containers.js</a> |
| 198 | +<span>, </span> |
| 199 | +<a href="https://github.com/technote-space/dockops/blob/master/containers.js#L97">lineno 97</a> |
| 200 | +</li> |
| 201 | +</ul></dd> |
| 202 | +</dl> |
| 203 | +</dd> |
| 204 | +</article> |
| 205 | +</section> |
| 206 | +</div> |
| 207 | +
|
| 208 | +*generated with [docme](https://github.com/technote-space/docme)* |
| 209 | +</div> |
| 210 | +<!-- END docme generated API please keep comment here to allow auto update --> |
| 211 | +
|
| 212 | +<h2>^License</h2> |
| 213 | +
|
| 214 | +MIT |
0 commit comments