-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths.js
51 lines (44 loc) · 1.27 KB
/
s.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var Docker = require('dockerode');
var sh = require('shelljs'); // To issue shell commands
var docker = new Docker({
socketPath: '/var/run/docker.sock'
});
// Clear all containers
var clearAllContainers = function () {
sh.exec('docker rm `docker ps --no-trunc -aq`', {
silent: true
}).output;
}
// Run commands
docker.createContainer({
Image: 'ncthis/ceresi',
Cmd: ['/bin/ls', '/stuff'],
"Volumes": {
"/stuff": {}
}
}, function (err, container) {
// Attach container
container.attach({
stream: true,
stdout: true,
stderr: true,
tty: true
}, function (err, stream) {
stream.pipe(process.stdout);
// Start container
container.start({
"Binds": ["/home/vagrant:/stuff"]
}, function (err, data) {
// Something to do
console.log("Container is now started...");
// Run docker container
docker.run('jolly_almeida', ['bash', '-c', 'uname -a'], [process.stdout, process.stderr], {
Tty: false
}, function (err, data, container) {
console.log(err);
console.log(data.StatusCode);
});
console.log("Container stopped");
});
});
});