脚本宝典收集整理的这篇文章主要介绍了Deploy NodeJS with node-red, mongodb, dashboard in Docker,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
docker File
Create this file wITh the name Dockerfile
and put into your PRoject root folder.
# specify the node base image with your desired version node:<version>
From node:8
WORKDIR /app
RUN chown -R node:node /usr/local/lib/node_modules
RUN chown -R node:node /usr/local/bin
USER node
RUN npm install node-red -g
RUN npm install node-red-node-mongodb -g
RUN npm i node-red/node-red-dashboard -g
# port 1880 for node-red-dashboard
EXPOSE 1880
CMD node-red
Important in the Docker File
You need to include the -g
behind, as if you don't the package won't be installed.
RUN npm install node-red -g
RUN npm install node-red-node-mongodb -g
RUN npm i node-red/node-red-dashboard -g
However, there will be permission error if you just do that. So you need to change the owner and switch the user before that.
RUN chown -R node:node /usr/local/lib/node_modules
RUN chown -R node:node /usr/local/bin
USER node
The Joy
Then you can build using docker build -t nodejs .
After running the docker image using docker run -it -p 1880:1880 nodejs
You can now access the node-red in your browser.
BTw, you could map multiple ports from the container to host by using multiple -p
option.
以上是脚本宝典为你收集整理的Deploy NodeJS with node-red, mongodb, dashboard in Docker全部内容,希望文章能够帮你解决Deploy NodeJS with node-red, mongodb, dashboard in Docker所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。