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

Solution to 1290 error when importing file data in mysql

Error scenario Use the mysql command in cmd to ad...

CentOS uses local yum source to build LAMP environment graphic tutorial

This article describes how to use the local yum s...

js to achieve a simple magnifying glass effect

This article shares the specific code of js to ac...

Ten Experiences in Presenting Chinese Web Content

<br /> Focusing on the three aspects of text...

Two ways to use react in React html

Basic Use <!DOCTYPE html> <html lang=&qu...

Vue implements the product tab of the product details page function

This article example shares the specific code of ...

How to set up a deployment project under Linux system

1. Modify the firewall settings and open the corr...

Detailed explanation of JDBC database link and related method encapsulation

Detailed explanation of JDBC database link and re...

Some functions of using tcpdump to capture packets in the Linux command line

tcpdump is a flexible and powerful packet capture...

Linux unlink function and how to delete files

1. unlink function For hard links, unlink is used...

MySQL SQL Optimization Tutorial: IN and RANGE Queries

First, let's talk about the in() query. It is...

Briefly explain the use of group by in sql statements

1. Overview Group by means to group data accordin...