Created
July 3, 2014 14:58
-
-
Save 5t111111/ec2b5bac272f9883c737 to your computer and use it in GitHub Desktop.
Dockerでpm2 ref: http://qiita.com/5t111111/items/8f1f91cf3c15c6cff52f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "docker-pm2", | |
"version": "0.0.1", | |
"description": "Docker pm2 example", | |
"main": "index.js", | |
"author": "5t111111", | |
"dependencies": { | |
"pm2": "latest" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World\n'); | |
}).listen(1337); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker build . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker run -P -d <イメージID> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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