Demo environment: Windows
Project Name: docker_ Demo
1、 Install docker
Download the docker installation package on the official website, and then install it directly
https://www.docker.com/
Download address of docker official website
Open directly after installation
Open the terminal command line and enter docker. The following information will appear, indicating that the installation is successful
Two core knowledge points of docker
Container and image
The whole life cycle of docker consists of three parts: image + container + repository
First, let’s go back to terminal command line operations
Input: docker images
If no image has been created, it is empty, as follows:
1. Write one first Node.js service
server.js
const koa = require('koa');
const app = new koa();
app.use(async ctx => {
ctx.body = 'hello docker'
})
app.listen(3000, ()=>{
console.log("server start on port: 3000");
});
2. Configuration package.json file
{
"name": "docker_demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"koa": "^2.11.0"
}
}