cat Dockerfile.node FROM centos MAINTAINER zha*****ch.cn ENV LANG en_US.UTF-8 RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone WORKDIR /home RUN mkdir node COPY node-v8.14.0-linux-x64.tar.gz /home/ COPY web-monitor /home/node/web-monitor RUN tar zxf /home/node-v8.14.0-linux-x64.tar.gz -C /home/node ENV PATH PATH=$PATH:$HOME/bin:/home/node/node-v8.14.0-linux-x64/bin RUN npm install cnpm -g WORKDIR /home/node/web-monitor EXPOSE 8002 ENTRYPOINT cnpm i && npm run ci && tail -f /root/logs/master-stdout.log
构建镜像 [root@weifeng02 dockerfile]# docker build -t web-monitor -f Dockerfile.node . Sending build context to Docker daemon 174.1 MB Step 1/14 : FROM centos ---> 1e1148e4cc2c **** Step 14/14 : ENTRYPOINT cnpm i && npm run ci && tail -f /root/logs/master-stdout.log ---> Using cache ---> f221cdd3dd0a Successfully built f221cdd3dd0a
命令启动docker 镜像 [root@weifeng02 dockerfile]# docker run -d -p 8002 web-monitor 68afcb89348a69781694f01afabb8658ce8ea2b4f15b160d33c3e9f394e8bc17 [root@weifeng02 dockerfile]# [root@weifeng02 dockerfile]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 68afcb89348a web-monitor "/bin/sh -c 'cnpm ..." 4 seconds ago Up 3 seconds 0.0.0.0:32784->8002/tcp elastic_heyrovsky