-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
36 lines (29 loc) · 963 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env node
/*
____ _
/ ___|__ _ __ _ __ _| |_ __ _ _ _
| | / _` |/ _` |/ _` | __/ _` | | | |
| |__| (_| | (_| | (_| | || (_| | |_| |
\____\__,_|\__, |\__,_|\__\__,_|\__, |
|___/ |___/
Thursday, July 21, 2016 7:34 PM
*/
var exec = require('child_process').exec;
var updateNotifier = require('update-notifier');
var program = require('commander');
var pkg = require('./package.json');
updateNotifier({pkg}).notify();
program
.option('-c, --container <string>', 'Docker container id')
.parse(process.argv);
function ipFinder(containerId) {
var cmd = `sudo docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${containerId}`;
exec(cmd, function(error, stdout, stderr) {
console.log(stdout);
});
}
if (program.container) {
ipFinder(program.container);
} else {
console.log('Please add container id \n Ex: dockerNetwork -c 12597ccd7f70');
}