Docker----Deploying ASP. core2.1 and modifying publications in Docker

Source: Internet
Author: User
Tags dotnet docker ps

This article focuses on how to run an ASP. NET core application in a Docker container, and then publish the update after modifying the system. This article uses a custom Docker file

System Requirements :

1. Docker is installed on the server or locally

First, create an ASP. NET Core 2.1 Web App (this section can be ignored if you can create a project skillfully)

Note that "Start Docker support" is not checked here.

Ii. Creating Docker files

After the project is created, in the root directory of the project, add a dockerfile file, note the file name.

In the Dockerfile file, add the following:

# Add the base image from the microsoft/dotnet:2.1-aspnetcore-runtime# container in the system's working space workdir/app# copy the files under the current folder into the System workspace copy of the container. /app# set the Docker container externally exposed port expose 80# container using ["dotnet", "System-initiated DLL"] to run the application # using entrypoint ["dotnet", "System-initiated DLL"] #或使用 CMD [" Dotnet "," System-initiated DLL "]entrypoint [" dotnet "," School.Web.dll "]

Modify the Dockerfile file properties

  

III. Publishing Applications

  

  Note In the release settings, the target runtime is portable, and I used to set the winX64 to discover that the runtime does not start up problems

Iv. publish the application to the server

Upload the application to the server using FTP or other tools. For example, I use FileZilla to upload files to the/home/ubuntu/work/project/csharp/school folder.

V. Create a mirror

In the application directory:/home/ubuntu/work/project/csharp/school (depending on your situation, which is the directory where dockerfile resides on the server), execute the Generate Image command.

  Note the mirror name behind . (school:1.0.0 is the identity image name and version information)

This will download the ASP. NET Core 2.1-aspnetcore-runtime base image and run the subsequent instructions in Dockerfile

Vi. creating and starting a container

  Note Here-V, mount the file on the server host, facilitate subsequent changes, you can directly restart the effective

When executed successfully, the school (container name) is output, which allows the Docker ps-a to see if the container is up and running. When the container status is displayed as up, it indicates a successful start.

Enter the server IP address +8000 port locally to successfully see the system running correctly.

VII. Application updates and releases

After the project starts normally, after attempting to modify the project's view page or controller, and then republish, upload the update to the corresponding project folder (/home/ubuntu/work/project/csharp/school) for the server.

Execute the command to update the project:

Docker Restart School

Refresh page in Browser view updates

Eight, error troubleshooting

1. When the boot container is the Discovery container state is exit, through the command: Docker logs School view the container startup error.

2. Can be checked against each of the above-mentioned process one by one points of attention.

Docker----Deploying ASP. core2.1 and modifying publications in Docker

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.