node:4.4.5

docker pull daocloud.io/library/node:4.4.5

安装express

docker run -it daocloud.io/library/node:4.4.5 /bin/bash
node -v 
npm -v 
npm install express –g 
npm install -g express-generator 
express --version

制作镜像

docker commit -m "node4.4.5+npm+express4.13.4"

dockerfile

FROM express:4.13.4
ADD bin/ /home/app/bin/
ADD node_modules/ /home/app/node_modules/
ADD public/ /home/app/public/
ADD routes/ /home/app/routes/
ADD views/ /home/app/views/
ADD app.js /home/app/app.js
ADD package.json /home/app/package.json
EXPOSE 3000
RUN chmod 777 /home/app/bin/www
ENTRYPOINT node /home/app/bin/www

运行

docker build -t app:1.0-SNAPSHOT . 
docker run -p 3000:3000 -d app:1.0-SNAPSHOT 
docker logs -f containerid

codecraft
11.9k 声望2k 粉丝

当一个代码的工匠回首往事时,不因虚度年华而悔恨,也不因碌碌无为而羞愧,这样,当他老的时候,可以很自豪告诉世人,我曾经将代码注入生命去打造互联网的浪潮之巅,那是个很疯狂的时代,我在一波波的浪潮上留下...