docker-remote-api
Basic http wrapper to call the docker remote api from node
npm install docker-remote-api
Usage
var docker =var request =requestrequest
API
request = docker(options)
options.host
should be an address to a docker instance i.e. /var/run/docker.sock
or 127.0.0.1:2375
.
All other options will be used as default values for get
, post
, put
, delete
.
If you omit the options.host
it will be set to $DOCKER_HOST
or /var/run/docker.sock
request.get(path, [options], cb)
Send a GET
request to the remote api. path
should be the request path i.e. /images/json
.
options
can contain the following
qs: foo:'bar' // set querystring parametersheaders: name: '...' // set request headersjson: true // return json instead of a streambuffer: true // return a buffer instead of a streamdrain: true // will drain the response stream before calling cbtimeout: 20000 // set request timeoutversion: 'v1.14' // set explicit api version
request.delete(path, [options], cb)
Send a DELETE
request. Similar options as request.get
post = request.post(path, [options], cb)
Send a POST
request. Similar options as request.get
except it returns a request stream
that you can pipe a request body to. If you are sending json you can set options.json = body
and body
will be stringified and sent as the request body.
If you do not have a request body set body: null
or remember to call post.end()
put = request.put(path, [options], cb)
Send a PUT
request. Similar options as request.post
License
MIT