docker-run
Start a docker image and attach to it
npm install docker-run
There is also a command line tool available
Usage
var run =var child =processstdinprocessstdinchildstdoutchildstderr
API
child = run(image, [options])
Where options can be
net: 'bridge' // network mode (auto | host | bridge). defaults to bridgetty: true // be a tty. defaults to falsefork: true // fork (do not attach stdio). defaults to falseremove: true // remove the container on stop. defaults to truedns: '8.8.8.8' // set custom dns serversports:8080: 8081 // expose container 8080 to host 8081volumes:'/root': '/tmp' // expose container /root to host /tmp'/root': '/tmp2:ro' // expose container /root to host /tmp2 as read onlylinks:'container-name': 'alias' // link container-name as aliasenv:FOO: 'bar' // set env varsentrypoint: '/bin/bash' // override entrypoint on container,{} // remoteOpts is the generated docker remote JSON
child.stdin
,child.stderr
,child.stdout
The stdio streams for the container. Is null
if fork: true
child.destroy()
Destroy the child container
child.resize(wid, hei)
Resize the container pty (if tty: true
)
Events
child.on('exit', exitCode)
Emitted when the container exits
child.on('spawn', containerId)
Emitted when the container is spawned
child.on('error', error)
Emitted if the container experiences a fatal error
Command line usage
To install the command line tool do
npm install -g docker-run
And then run
docker-run --help
To view the help. In general to run an image do
docker-run [image]
License
MIT