Skip to content

Instantly share code, notes, and snippets.

@papertigers
Last active February 24, 2016 02:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save papertigers/d3892a3f3ec51ff04c79 to your computer and use it in GitHub Desktop.
Save papertigers/d3892a3f3ec51ff04c79 to your computer and use it in GitHub Desktop.
restify docker demo
var restify = require('restify');
function respond(req, res, next) {
res.send('hello ' + req.params.name + '\n');
next();
}
var server = restify.createServer();
server.get('/hello/:name', respond);
server.head('/hello/:name', respond);
server.listen(8080, function() {
console.log('%s listening at %s', server.name, server.url);
});
console.log("Super Docker Center");

Run a container quickly with the basic restify demo

docker run -p 8080:8080 -d -v http://git.io/restify-docker:/tmp/demo.js --name restify_demo node:slim bash -c "cd /tmp ;  npm install restify ; node demo.js"

Now curl the restify instance

curl $(sdc-listmachines | json -aH -c "'restify_demo' == this.name" ips.1):8080/hello/mike; echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment