Docker deploys net5 program to achieve cross-platform functions

Docker deploys net5 program to achieve cross-platform functions

Deployment environment: docker container, liunx system, VmWare virtual machine is used here, and MobaXterm tool is used to realize terminal connection to linux system

2. (Environment preparation) Start the virtual machine and connect the terminal to 192.168.20.128 (you will directly use this address to access the .NET5 project later)

The Linux system uses ifconfig to view the IP address and uses MobaXterm in the host machine (for details on the use of MobaXterm, see: https://www.jb51.net/article/212323.htm

3. Create a .NET5 project. This project creates asp.net core mvc

In addition, you need to right-click the project to add Docker support (method 1)

You can also create a project (method 2)

After adding docker support, the project will generate a Dockerfile as follows: (It is a file that contains all the dependent environments of the image)

The project is started locally as shown below:

4. Regarding Docker installation, I still recommend that you go directly to the official website, which is very detailed.

Installation address (Linux system): https://docs.docker.com/engine/install/centos/

5. Use docker to deploy the project after successful installation

(1) After successful installation, enter the docker info command as follows to indicate successful installation

(2) Import the project into a custom directory. Here I created a .NET5 folder in the home directory and placed the project in that folder.

After completion, enter: cd /home/NET5/DockerTest/ as follows

(3) Generate the project image docker build -t demo .

demo is the name of the image. Be careful not to miss the decimal point after demo.

After the image is successfully generated, view the image: docker images

(4) Generate a container with the image just generated and start a process (that is, start the project)

docker run -d --name cdb -p 8089:80 demo--Specify the port to generate the container image cdb as the container name and start a process

The port number is 8089, and cdb is the container name. Of course, you can generate multiple container names according to the specified image name demo to start multiple processes. Each container is isolated from each other.

The results are as follows:

Use the host machine to access this project:

192.168.20.128:8089 (can be accessed normally)

View container information: docker ps (cdb is the container just generated and related port information)

Then continue to generate a container and continue to use the command just now (cdb2 new container name)

Continue to start this port process 192.168.20.128:8090 (can also be accessed normally)

docker ps -- view container information

docker stop 14e79874c983 --Stop the container with id=14e79874c983

docker rm 14e79874c983 -- delete the container with id = 14e79874c983 docker logs cyx2 -- view the print log information of the container named cyx2

Appendix related docker command operation documents This brother's is good https://www.cnblogs.com/DeepInThought/p/10896790.html, the official website is also very complete

To sum up: I have been learning Docker recently. This article only shows the basic deployment of .Net5 projects using Docker containers. Of course, there are still many shortcomings. If you have any questions, please feel free to comment and give me some advice.

I feel a bit sleepy at night. I was going to chat a little more about docker mounting and other related operations. I will update later when I have time.

The above is the details of Docker deploying net5 programs to achieve cross-platform functions. For more information about Docker deploying net5 programs, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Process analysis of deploying ASP.NET Core applications on Linux system Docker
  • How to deploy .NET 5 on Docker
  • Complete steps for deploying Asp.net core applications with docker
  • ASP.NET Core Docker deployment in detail
  • Deploy .Net6 project to docker

<<:  What is the difference between HTM and HTML? What is the difference between HTM and HTML?

>>:  The qualities and abilities a web designer should have

Recommend

MySQL method steps to determine whether it is a subset

Table of contents 1. Problem 2. Solution Option 1...

CSS code to distinguish ie8/ie9/ie10/ie11 chrome firefox

Website compatibility debugging is really annoyin...

Detailed explanation of MySQL foreign key constraints

Official documentation: https://dev.mysql.com/doc...

Complete code for implementing the vue backtop component

Effect: Code: <template> <div class=&quo...

Introduction to MySQL overall architecture

The overall architecture of MySQL is divided into...

A brief analysis of Linux network programming functions

Table of contents 1. Create a socket 2. Bind sock...

Automatic failover of slave nodes in replication architecture in MySQL 8.0.23

I have been in contact with MGR for some time. Wi...

Summary of English names of Chinese fonts

When using the font-family property in CSS to ref...

JavaScript function detailed introduction

Any number of statements can be encapsulated thro...

Testing of hyperlink opening target

The target attribute of a link determines where th...

Vue uses rules to implement form field validation

There are many ways to write and validate form fi...

Detailed explanation of how to create an array in JavaScript

Table of contents Creating Arrays in JavaScript U...