我是 docker 新手,我正在尝试测试节点服务器
文件
FROM node:8
WORKDIR /home/test-ci-node
COPY . .
EXPOSE 8080
CMD [ "node", "server.js" ]
Run Code Online (Sandbox Code Playgroud)
服务器.js
var http = require('http');
//create a server object:
http.createServer(function (req, res) {
console.log("got req");
res.write('Hello World'); //write a response to the client
res.end(); //end the response
}).listen(8080); //the server object listens on port 8080
console.log("listining at 8080");
Run Code Online (Sandbox Code Playgroud)
我用命令启动了我的 docker 镜像
码头工人运行 -p 8080:8080 -d docker_img
现在在server.js 中,我将响应更改为
res.write('Hello World 改变了!');
然后我尝试重新启动容器但没有反映更改,我尝试了一些谷歌方法但结果相同。
为了反映变化,我不得不重建图像。
那么有没有正确的方法来反映更改而不重建图像。