Skip to content

Instantly share code, notes, and snippets.

@lvidarte
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lvidarte/9254883 to your computer and use it in GitHub Desktop.
Save lvidarte/9254883 to your computer and use it in GitHub Desktop.
Node.js Hello World app on Ubuntu using docker
var express = require('express');
var port = 8080;
var app = express();
app.get('/', function (req, res) {
res.send('Hello World\n');
});
app.listen(port)
console.log('Running on http://localhost:' + port);
FROM ubuntu:13.10
RUN apt-get update
RUN apt-get install -y nodejs npm
ADD . /src
RUN cd /src; npm install
EXPOSE 8080
CMD ["nodejs", "/src/app.js"]
{
"name": "ubuntu-node-hello",
"private": true,
"version": "0.0.1",
"description": "Node.js Hello World app on Ubuntu using docker",
"author": "Leonardo Vidarte <lvidarte@gmail.com>",
"dependencies": {
"express": "3.2.4"
}
}
@lvidarte
Copy link
Author

Then build the image

docker build -t <your username>/ubuntu-node-hello .

And run the image

docker run -p 49160:8080 -d <your username>/ubuntu-node-hello

Check the app on http://localhost:49160

@lvidarte
Copy link
Author

@lvidarte
Copy link
Author

Download my image created by the above code

docker pull lvidarte/ubuntu-node-hello

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment