.NET Core 3.0 deployment running on the docker

Since .NET  after Core3.0 released, wrote several articles about .NET  articles Core 3.0 will help you quick start .NET  Core3.0.

This article basically explains step by step how to create a mvc project, and then publish and deploy runs on Docker. You need to have a docker local environment

  1. .Net Core3.0 configuration Configuration
  2. .Net Core3.0 use gRPC
  3. .NET Core3.0 created Worker Services
  4. .Net Core3.0 log logging
  5. .Net Core3.0 dependency injection DI
  6. .NET Core 3.0 Middleware Middleware
  7. .Net 5.0: .Net future - translation

1. Create a site

Creating a ASP.NET Core Web application, check Enable Docker support. Automatically help us create a Dockerfile file.

2. Write Dockerfile file

dockerfile file format is a profile, the user can use to quickly build dockerfile custom image. Statements by the command line by line, and supports comment lines beginning with #.

dockerfile subject matter is generally divided into four parts

  1. Information base image
  2. Instruction information using the label maintainer
  3. Mirror operation instruction
  4. When the container starts execution instruction
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
WORKDIR /app
EXPOSE 80
COPY . .
ENTRYPOINT ["dotnet", "AA.Mvc.dll"]

dockerfile file Instructions:

  • FROM - Specifies the base image to create a mirror image
  • WORKDIR- configure the working directory
  • Within EXPOSE- statement mirrored listening service port
  • COPY- copy the contents to the mirror
  • ENTRYPOINT- population default boot image command

Compile publish web project

3. The site is published, xftp upload centos

Use xftp upload centos system

4. Construction of the mirror, and browse the container run

 4.1 Create a mirror, you can use the command docker build, as follows:

docker build -t core-mvc .

Decomposition parameters:

  • -t --- specify the image name
  • At the end of the command  .  --- expressed build context for the current directory, by default docker will be used to find files in the root directory Dockerfile context

4.2 view mirror list, enter the following command

docker images

4.3 Create and start to view the container

ocker run --name netcore-mvc -d -p 50879:80  core-mvc
docker ps -a

 Parameter Description

  • -d, run as a guard state (daemonized) in the form of a container in the background
  • -p external port and the internal port mapping the container.
  • --name Specifies the name of the container. Of course, you can not specified, the default will be created for us
  • The last parameter is mirrored core-mvc name we just created

After the above four steps, enter the address in a browser http://192.168.92.130:50879 See FIG.

At this point a complete project in a manual way to run docker container. 

Welcome to the micro-channel group, with the exchange

 

Guess you like

Origin www.cnblogs.com/chengtian/p/11832955.html