Skip to content

Commit b0ffbde

Browse files
committed
inspect 1.0.8
1 parent bd5eff9 commit b0ffbde

5 files changed

Lines changed: 243 additions & 9 deletions

File tree

Gruntfile.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
var mkdirp = require('mkdirp');
2-
var fs = require('fs');
1+
var fs = require('fs');
32

43
module.exports = function (grunt) {
54
var config = require('./my_config.json');//use config.json as example

README.md

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,206 @@ docker.command('network ls').then(function (data) {
297297
// driver: 'bridge'
298298
// }]
299299
//}
300+
```
301+
302+
* docker inspect
303+
```js
304+
305+
docker.command('inspect consul').then(function (data) {
306+
console.log('data = ', data);
307+
});
308+
309+
310+
//data = { command: 'docker inspect consul ',
311+
// raw: '["[\\n{\\n \\"Id\\": \\"2e91854b5dd01a1bb9a8c67757264f32cd512385502f365321771bf669b0ff62\\",\\n \\"Created\\": \\"2016-01-14T01:53:08.855624531Z\\",\\n \\"Path\\": \\"/run.sh\\",\\n \\"Args\\": [\\n \\"agent\\",\\n \\"-config-file\\",\\n \\"/var/consul/config/config.json\\",\\n \\"-bootstrap\\"\\n ],\\n
312+
// \\"State\\": {\\n \\"Status\\": \\"running\\",\\n \\"Running\\": true,\\n \\"Paused\\": false,\\n \\"Restarting\\": false,\\n \\"OOMKilled\\": false,\\n \\"Dead\\": false,\\n \\"Pid\\": 1913,\\n \\"ExitCode\\": 0,\\n \\"Error\\": \\"\\",\\n \\"StartedAt\\": \\"2016-01-14T01:53:08.999561111Z\\",\\n \\"FinishedAt\\": \\"0001-01-01T00:00:00Z\\"\\n },\\n \\"Image\\": \\"c2e8640282e5e8c0ed4efbffe661ebc9a3c6819fb3378f54eab6310a3754edc8\\",\\n \\"ResolvConfPath\\": \\"/var/lib/docker/containers/2e91854b5dd01a1bb9a8c67757264f32cd512385502f365321771bf669b0ff62/resolv.conf\\",\\n \\"HostnamePath\\": \\"/var/lib/docker/containers/2e91854b5dd01a1bb9a8c67757264f32cd512385502f365321771bf669b0ff62/hostname\\",\\n \\"HostsPath\\": \\"/var/lib/docker/containers/2e91854b5dd01a1bb9a8c67757264f32cd512385502f365321771bf669b0ff62/hosts\\",\\n \\"LogPath\\": \\"/var/lib/docker/containers/2e91854b5dd01a1bb9a8c67757264f32cd512385502f365321771bf669b0ff62/2e91854b5dd01a1bb9a8c67757264f32cd512385502f365321771bf669b0ff62-json.log\\",\\n \\"Name\\": \\"/consul\\",\\n \\"RestartCount\\": 0,\\n \\"Driver\\": \\"aufs\\",\\n \\"ExecDriver\\": \\"native-0.2\\",\\n \\"MountLabel\\": \\"\\",\\n \\"ProcessLabel\\": \\"\\",\\n \\"AppArmorProfile\\": \\"\\",\\n \\"ExecIDs\\": null,\\n \\"HostConfig\\": {\\n \\"Binds\\": [\\n \\"/fleetmake/data/consul/log:/var/consul/log\\",\\n \\"/fleetmake/data/consul/data:/var/consul/data\\",\\n \\"/fleetmake/data/consul/conf:/var/consul/config\\"\\n ],\\n \\"ContainerIDFile\\": \\"\\",\\n \\"LxcConf\\": [],\\n \\"Memory\\": 0,\\n \\"MemoryReservation\\": 0,\\n
313+
// \\"MemorySwap\\": 0,\\n \\"KernelMemory\\": 0,\\n \\"CpuShares\\": 0,\\n \\"CpuPeriod\\": 0,\\n \\"CpusetCpus\\": \\"\\",\\n \\"CpusetMems\\": \\"\\",\\n \\"CpuQuota\\": 0,\\n \\"BlkioWeight\\": 0,\\n \\"OomKillDisable\\": false,\\n \\"MemorySwappiness\\": -1,\\n \\"Privileged\\": false,\\n \\"PortBindings\\": {\\n \\"8300/tcp\\": [\\n {\\n \\"HostIp\\": \\"\\",\\n \\"HostPort\\": \\"8300\\"\\n }\\n ],\\n \\"8301/tcp\\": [\\n {\\n \\"HostIp\\": \\"\\",\\n \\"HostPort\\": \\"8301\\"\\n }\\n ],\\n \\"8301/udp\\": [\\n {\\n
314+
// \\"HostIp\\": \\"\\",\\n \\"HostPort\\": \\"8301\\"\\n }\\n ],\\n
315+
// \\"8302/tcp\\": [\\n {\\n \\"HostIp\\": \\"\\",\\n \\"HostPort\\": \\"8302\\"\\n }\\n ],\\n \\"8302/udp\\": [\\n {\\n
316+
// \\"HostIp\\": \\"\\",\\n \\"HostPort\\": \\"8302\\"\\n }\\n ],\\n
317+
// \\"8400/tcp\\": [\\n {\\n \\"HostIp\\": \\"\\",\\n \\"HostPort\\": \\"8400\\"\\n }\\n ],\\n \\"8500/tcp\\": [\\n {\\n
318+
// \\"HostIp\\": \\"\\",\\n \\"HostPort\\": \\"8500\\"\\n }\\n
319+
//],\\n \\"8600/tcp\\": [\\n {\\n \\"HostIp\\": \\"\\",\\n
320+
// \\"HostPort\\": \\"8600\\"\\n }\\n ],\\n \\"8600/udp\\": [\\n {\\n \\"HostIp\\": \\"\\",\\n \\"HostPort\\": \\"8600\\"\\n }\\n
321+
//]\\n },\\n \\"Links\\": null,\\n \\"PublishAllPorts\\": false,\\n \\"Dns\\": [],\\n
322+
//\\"DnsOptions\\": [],\\n \\"DnsSearch\\": [],\\n \\"ExtraHosts\\": null,\\n \\"VolumesFrom\\": null,\\n \\"Devices\\": [],\\n \\"NetworkMode\\": \\"host\\",\\n \\"IpcMode\\": \\"\\",\\n
323+
//\\"PidMode\\": \\"\\",\\n \\"UTSMode\\": \\"\\",\\n \\"CapAdd\\": null,\\n \\"CapDrop\\": null,\\n \\"GroupAdd\\": null,\\n \\"RestartPolicy\\": {\\n \\"Name\\": \\"no\\",\\n \\"MaximumRetryCount\\": 0\\n },\\n \\"SecurityOpt\\": null,\\n \\"ReadonlyRootfs\\": false,\\n
324+
//\\"Ulimits\\": null,\\n \\"LogConfig\\": {\\n \\"Type\\": \\"json-file\\",\\n \\"Config\\": {}\\n },\\n \\"CgroupParent\\": \\"\\",\\n \\"ConsoleSize\\": [\\n 0,\\n
325+
// 0\\n ],\\n \\"VolumeDriver\\": \\"\\"\\n },\\n \\"GraphDriver\\": {\\n \\"Name\\": \\"aufs\\",\\n \\"Data\\": null\\n },\\n \\"Mounts\\": [\\n {\\n \\"Source\\": \\"/fleetmake/data/consul/log\\",\\n \\"Destination\\": \\"/var/consul/log\\",\\n \\"Mode\\": \\"\\",\\n
326+
// \\"RW\\": true\\n },\\n {\\n \\"Source\\": \\"/fleetmake/data/consul/data\\",\\n
327+
// \\"Destination\\": \\"/var/consul/data\\",\\n \\"Mode\\": \\"\\",\\n \\"RW\\": true\\n },\\n {\\n \\"Source\\": \\"/fleetmake/data/consul/conf\\",\\n \\"Destination\\": \\"/var/consul/config\\",\\n \\"Mode\\": \\"\\",\\n \\"RW\\": true\\n }\\n ],\\n \\"Config\\": {\\n \\"Hostname\\": \\"atomix\\",\\n \\"Domainname\\": \\"\\",\\n \\"User\\": \\"\\",\\n
328+
// \\"AttachStdin\\": false,\\n \\"AttachStdout\\": false,\\n \\"AttachStderr\\": false,\\n \\"ExposedPorts\\": {\\n \\"8300/tcp\\": {},\\n \\"8301/tcp\\": {},\\n \\"8301/udp\\": {},\\n
329+
// \\"8302/tcp\\": {},\\n \\"8302/udp\\": {},\\n \\"8400/tcp\\": {},\\n \\"8500/tcp\\": {},\\n \\"8600/tcp\\": {},\\n \\"8600/udp\\": {}\\n },\\n \\"Tty\\": false,\\n \\"OpenStdin\\": false,\\n \\"StdinOnce\\": false,\\n \\"Env\\": [\\n \\"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\\",\\n \\"CONSUL_VERSION=0.5.2\\",\\n \\"CONSUL_SHA256=171cf4074bfca3b1e46112105738985783f19c47f4408377241b868affa9d445\\"\\n ],\\n \\"Cmd\\": [\\n \\"agent\\",\\n \\"-config-file\\",\\n \\"/var/consul/config/config.json\\",\\n
330+
// \\"-bootstrap\\"\\n ],\\n \\"Image\\": \\"quobjectio/consul:0.5.2\\",\\n \\"Volumes\\": {\\n \\"/var/consul/config\\": {},\\n \\"/var/consul/data\\": {},\\n \\"/var/consul/log\\": {}\\n },\\n \\"WorkingDir\\": \\"\\",\\n \\"Entrypoint\\": [\\n \\"/run.sh\\"\\n
331+
//],\\n \\"OnBuild\\": null,\\n \\"Labels\\": {},\\n \\"StopSignal\\": \\"SIGTERM\\"\\n },\\n \\"NetworkSettings\\": {\\n \\"Bridge\\": \\"\\",\\n \\"SandboxID\\": \\"bc04a89e70c29498c25a32472c62a01b8de7d12b31a856b539d66a344df079a2\\",\\n \\"HairpinMode\\": false,\\n \\"LinkLocalIPv6Address\\": \\"\\",\\n \\"LinkLocalIPv6PrefixLen\\": 0,\\n \\"Ports\\": {},\\n \\"SandboxKey\\": \\"/var/run/docker/netns/default\\",\\n \\"SecondaryIPAddresses\\": null,\\n \\"SecondaryIPv6Addresses\\": null,\\n
332+
//\\"EndpointID\\": \\"\\",\\n \\"Gateway\\": \\"\\",\\n \\"GlobalIPv6Address\\": \\"\\",\\n \\"GlobalIPv6PrefixLen\\": 0,\\n \\"IPAddress\\": \\"\\",\\n \\"IPPrefixLen\\": 0,\\n \\"IPv6Gateway\\": \\"\\",\\n \\"MacAddress\\": \\"\\",\\n \\"Networks\\": {\\n \\"host\\": {\\n
333+
//\\"EndpointID\\": \\"aeba20b34a47596646044493147fb1eafd5b4b76a3688f9b5c450b1dfe2bfdfb\\",\\n \\"Gateway\\": \\"\\",\\n \\"IPAddress\\": \\"\\",\\n \\"IPPrefixLen\\": 0,\\n \\"IPv6Gateway\\": \\"\\",\\n \\"GlobalIPv6Address\\": \\"\\",\\n \\"GlobalIPv6PrefixLen\\": 0,\\n \\"MacAddress\\": \\"\\"\\n }\\n }\\n }\\n}\\n]\\n",""]',
334+
//object:
335+
//[ { Id: '2e91854b5dd01a1bb9a8c67757264f32cd512385502f365321771bf669b0ff62',
336+
// Created: '2016-01-14T01:53:08.855624531Z',
337+
// Path: '/run.sh',
338+
// Args:
339+
// [ 'agent',
340+
// '-config-file',
341+
// '/var/consul/config/config.json',
342+
// '-bootstrap' ],
343+
// State:
344+
// { Status: 'running',
345+
// Running: true,
346+
// Paused: false,
347+
// Restarting: false,
348+
// OOMKilled: false,
349+
// Dead: false,
350+
// Pid: 1913,
351+
// ExitCode: 0,
352+
// Error: '',
353+
// StartedAt: '2016-01-14T01:53:08.999561111Z',
354+
// FinishedAt: '0001-01-01T00:00:00Z' },
355+
// Image: 'c2e8640282e5e8c0ed4efbffe661ebc9a3c6819fb3378f54eab6310a3754edc8',
356+
// ResolvConfPath: '/var/lib/docker/containers/2e91854b5dd01a1bb9a8c67757264f32cd512385502f365321771bf669b0ff62/resolv.conf',
357+
// HostnamePath: '/var/lib/docker/containers/2e91854b5dd01a1bb9a8c67757264f32cd512385502f365321771bf669b0ff62/hostname',
358+
// HostsPath: '/var/lib/docker/containers/2e91854b5dd01a1bb9a8c67757264f32cd512385502f365321771bf669b0ff62/hosts',
359+
// LogPath: '/var/lib/docker/containers/2e91854b5dd01a1bb9a8c67757264f32cd512385502f365321771bf669b0ff62/2e91854b5dd01a1bb9a8c67757264f32cd512385502f365321771bf669b0ff62-json.log',
360+
// Name: '/consul',
361+
// RestartCount: 0,
362+
// Driver: 'aufs',
363+
// ExecDriver: 'native-0.2',
364+
// MountLabel: '',
365+
// ProcessLabel: '',
366+
// AppArmorProfile: '',
367+
// ExecIDs: null,
368+
// HostConfig:
369+
// { Binds:
370+
// [ '/fleetmake/data/consul/log:/var/consul/log',
371+
// '/fleetmake/data/consul/data:/var/consul/data',
372+
// '/fleetmake/data/consul/conf:/var/consul/config' ],
373+
// ContainerIDFile: '',
374+
// LxcConf: [],
375+
// Memory: 0,
376+
// MemoryReservation: 0,
377+
// MemorySwap: 0,
378+
// KernelMemory: 0,
379+
// CpuShares: 0,
380+
// CpuPeriod: 0,
381+
// CpusetCpus: '',
382+
// CpusetMems: '',
383+
// CpuQuota: 0,
384+
// BlkioWeight: 0,
385+
// OomKillDisable: false,
386+
// MemorySwappiness: -1,
387+
// Privileged: false,
388+
// PortBindings:
389+
// { '8300/tcp': [ { HostIp: '', HostPort: '8300' } ],
390+
// '8301/tcp': [ { HostIp: '', HostPort: '8301' } ],
391+
// '8301/udp': [ { HostIp: '', HostPort: '8301' } ],
392+
// '8302/tcp': [ { HostIp: '', HostPort: '8302' } ],
393+
// '8302/udp': [ { HostIp: '', HostPort: '8302' } ],
394+
// '8400/tcp': [ { HostIp: '', HostPort: '8400' } ],
395+
// '8500/tcp': [ { HostIp: '', HostPort: '8500' } ],
396+
// '8600/tcp': [ { HostIp: '', HostPort: '8600' } ],
397+
// '8600/udp': [ { HostIp: '', HostPort: '8600' } ] },
398+
// Links: null,
399+
// PublishAllPorts: false,
400+
// Dns: [],
401+
// DnsOptions: [],
402+
// DnsSearch: [],
403+
// ExtraHosts: null,
404+
// VolumesFrom: null,
405+
// Devices: [],
406+
// NetworkMode: 'host',
407+
// IpcMode: '',
408+
// PidMode: '',
409+
// UTSMode: '',
410+
// CapAdd: null,
411+
// CapDrop: null,
412+
// GroupAdd: null,
413+
// RestartPolicy: { Name: 'no', MaximumRetryCount: 0 },
414+
// SecurityOpt: null,
415+
// ReadonlyRootfs: false,
416+
// Ulimits: null,
417+
// LogConfig: { Type: 'json-file', Config: {} },
418+
// CgroupParent: '',
419+
// ConsoleSize: [ 0, 0 ],
420+
// VolumeDriver: '' },
421+
// GraphDriver: { Name: 'aufs', Data: null },
422+
// Mounts:
423+
// [ { Source: '/fleetmake/data/consul/log',
424+
// Destination: '/var/consul/log',
425+
// Mode: '',
426+
// RW: true },
427+
// { Source: '/fleetmake/data/consul/data',
428+
// Destination: '/var/consul/data',
429+
// Mode: '',
430+
// RW: true },
431+
// { Source: '/fleetmake/data/consul/conf',
432+
// Destination: '/var/consul/config',
433+
// Mode: '',
434+
// RW: true } ],
435+
// Config:
436+
// { Hostname: 'atomix',
437+
// Domainname: '',
438+
// User: '',
439+
// AttachStdin: false,
440+
// AttachStdout: false,
441+
// AttachStderr: false,
442+
// ExposedPorts:
443+
// { '8300/tcp': {},
444+
// '8301/tcp': {},
445+
// '8301/udp': {},
446+
// '8302/tcp': {},
447+
// '8302/udp': {},
448+
// '8400/tcp': {},
449+
// '8500/tcp': {},
450+
// '8600/tcp': {},
451+
// '8600/udp': {} },
452+
// Tty: false,
453+
// OpenStdin: false,
454+
// StdinOnce: false,
455+
// Env:
456+
// [ 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
457+
// 'CONSUL_VERSION=0.5.2',
458+
// 'CONSUL_SHA256=171cf4074bfca3b1e46112105738985783f19c47f4408377241b868affa9d445' ],
459+
// Cmd:
460+
// [ 'agent',
461+
// '-config-file',
462+
// '/var/consul/config/config.json',
463+
// '-bootstrap' ],
464+
// Image: 'quobjectio/consul:0.5.2',
465+
// Volumes:
466+
// { '/var/consul/config': {},
467+
// '/var/consul/data': {},
468+
// '/var/consul/log': {} },
469+
// WorkingDir: '',
470+
// Entrypoint: [ '/run.sh' ],
471+
// OnBuild: null,
472+
// Labels: {},
473+
// StopSignal: 'SIGTERM' },
474+
// NetworkSettings:
475+
// { Bridge: '',
476+
// SandboxID: 'bc04a89e70c29498c25a32472c62a01b8de7d12b31a856b539d66a344df079a2',
477+
// HairpinMode: false,
478+
// LinkLocalIPv6Address: '',
479+
// LinkLocalIPv6PrefixLen: 0,
480+
// Ports: {},
481+
// SandboxKey: '/var/run/docker/netns/default',
482+
// SecondaryIPAddresses: null,
483+
// SecondaryIPv6Addresses: null,
484+
// EndpointID: '',
485+
// Gateway: '',
486+
// GlobalIPv6Address: '',
487+
// GlobalIPv6PrefixLen: 0,
488+
// IPAddress: '',
489+
// IPPrefixLen: 0,
490+
// IPv6Gateway: '',
491+
// MacAddress: '',
492+
// Networks:
493+
// { host:
494+
// { EndpointID: 'aeba20b34a47596646044493147fb1eafd5b4b76a3688f9b5c450b1dfe2bfdfb',
495+
// Gateway: '',
496+
// IPAddress: '',
497+
// IPPrefixLen: 0,
498+
// IPv6Gateway: '',
499+
// GlobalIPv6Address: '',
500+
// GlobalIPv6PrefixLen: 0,
501+
// MacAddress: '' } } } } ] }
300502
```

lib/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,18 @@ var extractResult = function (result) {
157157

158158
return resultp;
159159
}
160-
}
160+
},
161+
{
162+
re: / inspect /,
163+
run: function (resultp) {
164+
var obj = JSON.parse(resultp.raw);
165+
var object = JSON.parse(obj[0]);
166+
167+
resultp.object = object;
168+
169+
return resultp;
170+
}
171+
},
161172

162173

163174

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "docker-cli-js",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "A wrapper for the docker CLI",
55
"main": "lib/index.js",
66
"scripts": {

test/index.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var Docker = require('../lib/index.js');
44
var path = require('path');
55
var should = require('chai').should();
66
var assert = require('chai').assert;
7-
7+
var util = require('util');
88
var dockermachine = require('dockermachineconfig');
99

1010
var config = require('../my_config.json');
@@ -186,14 +186,36 @@ describe('docker', function () {
186186
// });
187187
//});
188188

189-
it('command network ls', function (done) {
189+
//it('command network ls', function (done) {
190+
// this.timeout(15000);
191+
// var docker = new Docker({});
192+
// assert.isNotNull(docker);
193+
// var failed = false;
194+
// var err = null;
195+
// docker.command('--tlsverify --tlscacert="/home/apollo/.docker/machine/certs/ca.pem" --tlscert="/home/apollo/.docker/machine/certs/cert.pem" --tlskey="/home/apollo/.docker/machine/certs/key.pem" -H=tcp://52.62.82.61:3376 network ls').then(function (data) {
196+
// console.log('data = ', data);
197+
// assert.isNotNull(data);
198+
// }).catch(function (error) {
199+
// assert.isNotNull(error);
200+
// err = error;
201+
// failed = true;
202+
// console.log('error = ', error);
203+
// }).finally(function () {
204+
// console.log('finally ');
205+
// assert.isFalse(failed);
206+
// assert.isNull(err);
207+
// done();
208+
// });
209+
//});
210+
211+
it('command inspect consul', function (done) {
190212
this.timeout(15000);
191-
var docker = new Docker({});
213+
var docker = new Docker({});
192214
assert.isNotNull(docker);
193215
var failed = false;
194216
var err = null;
195-
docker.command('--tlsverify --tlscacert="/home/apollo/.docker/machine/certs/ca.pem" --tlscert="/home/apollo/.docker/machine/certs/cert.pem" --tlskey="/home/apollo/.docker/machine/certs/key.pem" -H=tcp://52.62.82.61:3376 network ls').then(function (data) {
196-
console.log('data = ', data);
217+
docker.command('inspect consul').then(function (data) {
218+
console.log('data = ', util.inspect(data, { depth: 10}));
197219
assert.isNotNull(data);
198220
}).catch(function (error) {
199221
assert.isNotNull(error);

0 commit comments

Comments
 (0)