Installation of Windows Docker, deploying ASP. NET Core program in Docker

Source: Internet
Author: User

Reference article:
Https://www.cnblogs.com/jRoger/p/aspnet-core-deploy-to-docker.html
Https://www.cnblogs.com/jRoger/p/aspnet-core-deploy-to-docker.html
Docker for Windows download connection: https://docs.docker.com/docker-for-windows/install/

The details of the configuration, as well as the download and installation of Docker, are described in detail in the article.
Since I've never had a virtual machine, I don't know anything about Linux ... So it was a half-day delay ...
As the company recently engaged in service, read some of the SOA-related materials, will be more or less mentioned Docker, I am very curious, hereby to study
So this article is mainly attached to a fool tutorial. And point out the points that need attention in the configuration.
Before reading this article, it is recommended to read the above two reference articles first
The contents of this article can be found in the reference articles without any detailed explanation.

First step: Install Docker for Windows

Before installing, you need to turn on the Hyper-V virtual machine feature to enable the ability to search yourself, Hyper-V boot, and also to enable CPU virtualization in the BIOS.
Well, if you're too lazy to query, I can send you a direct link to Baidu: https://jingyan.baidu.com/article/15622f24017461fdfdbea554.html
Until the virtualization display in Task Manager is turned on to indicate success

Step two: Create a WEBAPI program

Of course you can create one in VS or anywhere, and then publish the program

Step three: Create a dockerfile file

Create a text document in the root directory of Webapi Dockerfile.txt
Content:

# The underlying image used by the Declaration
From Microsoft/dotnet:latest
# Copy the local dotnet core app to the container/app/directory
COPY bin/debug/netcoreapp2.0/publish//app/
# set working directory
Workdir/app
# Set Export port
EXPOSE 5000/tcp
# Specify app entry point
entrypoint ["Dotnet", "/app/netcore.dll"]

This explains the next part of the argument

    • Line 1th: The mirror that represents the program needs to depend on which mirror : Latest indicates that the mirror version is the latest
    • Line 2nd: Copy your program folder to the Mirrored app directory
    • Last line:NetCore.dll is the DLL name of your API

Remember to remove the suffix of the file when you are done editing

Part III: Creating Mirrors

Enter the power Shell Interface
The CD command switches to the root directory of the Webapi
Execute command:
Docker build-t MyApi .
Note that the last point in the command represents a command that executes from your current directory
No surprises. Image Creation Complete

Then proceed to run the command:
Docker Run-it-p 5000:5000 MyApi
The 5,000:5,000 here means that the 5000 ports in the container are mapped to the 5000 ports on your host.
Then http://localhost:5000 will be able to visit!

Installation of Windows Docker, deploying ASP. NET Core program 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.