I try to mount a volume in docker container using nodejs app on windows. When I try this command on the cmd:
docker run -it -v C:\Users\User\data:/stuff:rw ubuntu bash
it works and the container contains the volume. But if I try to do this using nodejs (dockerode module), it does not work. My code:
var dockerode = require('dockerode');
var docker = new dockerode();
var stream = require('stream');
docker.createContainer({
Image: 'ubuntu',
Cmd: ['ls', 'stuff'],
'Volumes': {
'/stuff': {}
},
'Binds': ['C:\Users\User\data:/stuff:rw']
}, function(err, container) {
container.attach({
stream: true,
stdout: true,
stderr: true,
tty: true,
'Binds': ['C:\Users\User\data:/stuff:rw']
}, function(err, stream) {
stream.pipe(process.stdout);
container.start({
'Binds': ['C:\Users\User\data:/stuff:rw']
}, function(err, data) {
console.log(data);
});
});
});
The problem is that it prints nothing (the stuff directory is empty). When I use the same code on mac, it works fine. How can I fix it? thanks.