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

3 functions of toString method in js

Table of contents 1. Three functions of toString ...

A detailed introduction to Linux file permissions

The excellence of Linux lies in its multi-user, m...

The difference between clientWidth, offsetWidth, scrollWidth in JavaScript

1. Concept They are all attributes of Element, in...

More popular and creative dark background web design examples

Dark background style page design is very popular...

How to implement the webpage anti-copying function (with cracking method)

By right-clicking the source file, the following c...

SQL left join and right join principle and example analysis

There are two tables, and the records in table A ...

How to solve jQuery conflict problem

In front-end development, $ is a function in jQue...

Mysql database design three paradigm examples analysis

Three Paradigms 1NF: Fields are inseparable; 2NF:...

Detailed explanation of the process of using docker to build minio and java sdk

Table of contents 1minio is simple 2 Docker build...

What does the n after int(n) in MySQL mean?

You may already know that the length 1 of int(1) ...

IE8 Developer Tools Menu Explanation

<br />This article has briefly explained the...

Implementation of dynamic particle background plugin for Vue login page

Table of contents The dynamic particle effects ar...