The website made by ASP.NET CORE runs on docker (does not need to be deployed by dockerfile)

According to the online practice, it can be obtained by using the dockerfile file, http://www.docker.org.cn/article/119.html,

 

However, I want to put the website files in the external hard disk directory, and then map them into it, so I just need to restart the container after modifying the CSHTML file in the hard disk directory.

 

Proceed as follows:

 

1. Create an ASP.NET CORE website in vs, the class name is coreweb1

 

2. Publish to the c:\temp\coreweb1 directory

 

3. First test the success on the local CMD command line, cd c:\temp\coreweb1 , and then run docnet coreweb1.dll

 

4. There should be no accident, you can access the website by entering http://localhost:5000 in the browser

 

5. Exit the command line tool and start docker image deployment. The premise is that docker is installed first. If the mapped local port is 80, remember to stop IIS first (if you have IIS installed)

 

6. Enter the docker command docker run -p 8001:80 -vc:/temp/coreweb1:/wwwroot -w /wwwroot/microsoft/aspnetcore dotnet /wwwroot/coreweb1.dll in the command line CMD

 

        Explain the above command: run the docker container named microsoft/aspnetcore, which is Microsoft's official asp.net core image, map the local port 8001 to port 80 in the container, and map the local directory c:/temp/coreweb1 to the container /wwwroot directory in the container, set the working directory in the container to /wwwroot/, run the command dotnet /wwwroot/coreweb1.dll after the container is running

 

7. If you don't report an error, you should be able to see that the website is running. Enter http://localhost:8001 in the external browser and you should be able to access the website. Even if you press ctrl+c in the command line to exit, in fact, docker The container is also running, enter the command docker ps to see the running container

 

8. Create another asp.net core website in VS, the class name is coreweb2, and publish it to c:\temp\coreweb2,

 

9. Run the docker command to map port 8002: docker run -p 8002:80 -vc:/temp/coreweb2:/wwwroot -w /wwwroot/microsoft/aspnetcore dotnet /wwwroot/coreweb2.dll

 

10. In this way, the two core websites are deployed. Enter http://localhost:8001 and http://localhost:8002 in the browser to see the two websites respectively.

 

11. If the file in the external directory is modified, for example, the c:/temp/coreweb1/views/home/index.cshtml file is modified, then restart the docker container in the command line and refresh the browser to see the modified effect. Command: docker restart container ID, where the container ID is queried through docker ps, the first column in front is, you can only enter the first few letters

 

 

   

 

Summary: I have a dream to have the cheapest single-core 1G memory linux server on XX cloud, install nginx and docker, and then run asp.net core website, PHP website, JSP website, GO website, PYTHON through docker Website, NODE.JS website.....

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326518708&siteId=291194637