Skip to content

Instantly share code, notes, and snippets.

@5t111111
Created July 3, 2014 14:58
Show Gist options
  • Save 5t111111/ec2b5bac272f9883c737 to your computer and use it in GitHub Desktop.
Save 5t111111/ec2b5bac272f9883c737 to your computer and use it in GitHub Desktop.
FROM node
WORKDIR /nodeapp
ADD package.json /nodeapp/
ADD index.js /nodeapp/
RUN npm install
EXPOSE 1337
CMD ["node_modules/pm2/bin/pm2", "--no-daemon", "start", "index.js"]
{
"name": "docker-pm2",
"version": "0.0.1",
"description": "Docker pm2 example",
"main": "index.js",
"author": "5t111111",
"dependencies": {
"pm2": "latest"
}
}
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337);
$ docker build .
$ docker run -P -d <イメージID>
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f89174a4ac15 392c405d84f6 node_modules/pm2/bin 48 seconds ago Up 47 seconds 0.0.0.0:49169->1337/tcp sad_shockley
$ curl -i localhost:49169
HTTP/1.1 200 OK
Content-Type: text/plain
Date: Thu, 03 Jul 2014 14:57:45 GMT
Connection: keep-alive
Transfer-Encoding: chunked
Hello World
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment