我的NodeJS未在Docker环境中运行。具体来说,我的express
模块未加载到Docker容器中。
这是我到目前为止的设置:
server.js
var express = require('express')
var app = express();
app.get('/', function (req, res) {
res.end('Hello world');
})
var server = app.listen(9005, function () {
var host = server.address().address
var port = server.address().port
console.log("Example app listening at http://%s:%s", host, port)
})
Dockerfile
FROM stefanscherer/node-windows:7.6.0-nano
# Create app directory
RUN mkdir -p /app
WORKDIR /app
# Install app dependencies
COPY package.json /app/
RUN npm install
# Bundle app source
COPY . /app
CMD ["node","server.js"]
EXPOSE 9005
答案 0 :(得分:0)
您确定在package.json的依赖项部分中包含了express吗?