Continue from Docker image lqwangxg/docker-node:latest.
1. Show workdir
$ cd ~/app/docker-node && ls
Dockerfile README.md index.js
package-lock.json package.json
2. Docker run container and npm install packages. (port:8080)
$ docker run -dp 3000:8080 \
-w /app/docker-node -v "$(pwd):/app/docker-node" \
lqwangxg/node:alpine \
sh -c "npm install -g nodemon && npm install && nodemon index.js"
#wait a moment. there will be cost some minutes on install packages
#nodemon is a source changed monitor, when source changed outside.
#nodemon will restart the server automatically.
$ curl -i localhost:3000
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 11
ETag: W/"b-Ck1VqNd45QIvq3AZd8XYQLvEhtA"
Date: Wed, 09 Sep 2020 05:14:00 GMT
Connection: keep-alive
Hello World
没有评论:
发表评论