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.
相关推荐
  boneix    2020-10-21  
   seanzed    2020-10-15  
   ifconfig    2020-10-14  
   学留痕    2020-09-20  
   往后余生    2020-09-17  
   kka    2020-09-14  
   redis    2020-09-07  
   lzccheng    2020-09-06  
   soyo    2020-08-31  
   stonerkuang    2020-08-18  
   LxyPython    2020-08-17  
   raksmart0    2020-08-17  
   Lzs    2020-08-14  
   MrHaoNan    2020-07-31  
   80530895    2020-07-05  
   lengyu0    2020-06-28  
   YarnSup    2020-06-28  
   huanglianhuabj00    2020-06-27