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]
Table of contents How to deploy MySQL service usi...
This article describes how to build a Nexus priva...
1. Download the MySQL jdbc driver (mysql-connecto...
Configuration Instructions Linux system: CentOS-7...
Docker virtualizes a bridge on the host machine. ...
Label display mode (important) div and span tags ...
Table of contents 1. Introduction 2. Main text 2....
MySQL official website zip file download link htt...
Table of contents 1. Closure 2. Closure usage sce...
MySQL advantage: Small size, fast speed, low tota...
Table of contents Show Me The Code Test the effec...
Table of contents 1. Project Description 2. Nginx...
background I am often asked about database transa...
Uninstall the system-provided MySQL 1. Check whet...
1. Go to the location where you want to store the...