Open joephon opened 4 years ago
mkdir node && cd node && vim app.js
// node/app.js const app = require('http') const PORT = 3000 app.createServer((req, res) => { res.end('Hello World!') }) app.listen(PORT, () => console.log(`Server is running on port: ${PORT}`))
vim Dockerfile
// node/Dockerfile FROM node:latest COPY . /app WORKDIRE /app EXPOSE 3000 CMD node ./app.js
docker build .
docker run -p 3000:3000 -d [your docker image id]
curl -get localhost:3000 // => Hello World!
Dependencies
Step 1 write your NodeJS code
Step 2 write your Dockerfile
Step 3 build your docker file
Step 4 run your app
Bingo~
这篇文章价值一块钱