nodejs的docker化

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
    原文地址: https://segmentfault.com/a/1190000005800939
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞