实际示例:
[root@node01 node]# ls dev-web dev-web.tar.gz Dockerfile node-v8.14.0-linux-x64.tar.gz package-lock.json
[root@node01 node]# cat Dockerfile FROM centos MAINTAINER zh*****ng@zh****ech.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 dev-web /home/node/dev-web 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 WORKDIR /home/node/dev-web EXPOSE 7000 ENTRYPOINT npm i && EGG_SERVER_ENV=dev npm run devstart && tail -f /home/node/dev-web/npm-debug.log
[root@node01 node]# docker build -t nodejs02 . Removing intermediate container b5baa4e62775 Successfully built 8facd65424a7
[root@node01 node]# docker run -d -p 7000:7000 nodejs02 053bcb1a8595c55c36744c37975ac83088dd8a0b8d74fb615ed81340e573c063
[root@node01 node]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 053bcb1a8595 nodejs02 "/bin/sh -c 'npm i..." 7 seconds ago Up 5 seconds 0.0.0.0:7000->7000/tcp keen_panini