$ mkdir centos7-expressjs

$ cd centos7-expressjs

$ vi Dockerfile

FROM centos:centos7

RUN yum install -y epel-release;yum install -y npm;

RUN npm install express --save

COPY . ./src

EXPOSE 8080

CMD ["node", "/src/index.js"]


$ vi index.js

var express = require('express'), app = express();

app.get('/', function (req, res) {res.send('Hello World!\n');});

app.listen(8080);


$ docker build -t knight76/centos7-expressjs .

$ docker run -p 8081:8080 -d  knight76/centos7-expressjs

$ curl -i localhost:8081

 

HTTP/1.1 200 OK

X-Powered-By: Express

Content-Type: text/html; charset=utf-8

Content-Length: 13

ETag: W/"d-jd2L5LF5pSmvpfL/rkuYWA"

Date: Tue, 26 Jul 2016 09:43:28 GMT

Connection: keep-alive


Hello World! 



----------------------


도커 허브에 업로드 한다.


우선 https://hub.docker.com에 이메일 계정으로 가입한다.



$ docker login

Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.

Username: 

Password:

Login Succeeded

  


$ docker push knight76/centos7-expressjs

(한국이라 그런지, push 시간이 오래 걸린다.)




$ docker search expressjs

NAME                                      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED

dmportella/expressjs                      Simple expressjs site with a status route ...   0

....

knight76/expressjs ...

Posted by '김용환'
,