System environment: Windows 7 1. Install DockerDownload and install docker-ToolBox from the Docker official website and install After the installation is complete, three icons appear: 2. Create a Docker imageDocker can automatically build images based on the contents of the Dockerfile file. Dockerfile is a text file that contains all the commands for creating an image. Use the docker build command to build an image based on its content. Example, create a Docker image of a NodeJS program: 1. Create a new directory and initialize it with npm init in cmd. 2. Create a demo program with the following contents: Note: If a formal product or project is packaged and released with Docker, such as the functional code in the above example, in order to prevent the source code from being extracted and leaked, the NodeJS code can be obfuscated and encrypted with JShaman before making the image. Create an empty file named Dockerfile and fill in the following content: FROM node:boron # Create app directory WORKDIR /app # Install app dependencies COPY package.json . # For npm@5 or later, copy package-lock.json as well # COPY package.json package-lock.json ./ RUN npm install # Bundle app source COPY . . EXPOSE 3000 CMD [ "node", "demo.js" ] 3. Create an image Start the Docker Quickstart Terminal and run the command
(. means creating in the current directory) 3. Run the imagedocker run -p 3000:3000 -d nodedemo Then you can access the nodejs service. The above is the details of installing Docker, creating images, loading and running NodeJS programs. For more information about docker NodeJS running programs, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: Solve the problem of Navicat for Mysql connection error 1251 (connection failed)
>>: 12 Laws of Web Design for Clean Code [Graphic]
Precautions 1) Add interpreter at the beginning: ...
Preface : Today I was asked, "Have you carefu...
Table of contents Demand Background Why use Nginx...
This article shares the specific code of js to im...
I'm currently working on my own small program...
1 Get the installation resource package mysql-8.0...
Generally speaking, the background color of a web ...
Table of contents The first method: router-link (...
1. Add skip-grant-tables to the my.ini file and r...
I believe that many partners who have just come i...
When an employer asks you whether an index will b...
Table of contents DOMContentLoaded and load What ...
1. Indexing principle Indexes are used to quickly...
This article shares the specific code of Element-...
MySQL DECIMAL data type is used to store exact nu...