Bingshennian imprisoned the real Monkey King in the container and ran ASP. NET Core 1.0, bingshencore

Source: Internet
Author: User
Tags net command net command line

Bingshennian imprisoned the real Monkey King in the container and ran ASP. NET Core 1.0, bingshencore
Bing shennian imprisoned the real Monkey King in a container and ran ASP. NET Core 1.0 Protocol ¶

Warning

The page you are viewing is unauthorized reprinted!
If the current version is incorrectly formatted, go to the latest version: http://www.cnblogs.com/qin-nz/p/aspnetcore-run-on-mono-in-year-of-monkey.html

Prompt

Updated on: July 15, February 07, 2016.

Dear programmers, happy year of monkey. I believe many Yuan/ape are attracted by titles. I will explain the title first.

Prompt

This article is a semi-Popular Science article that does not go deep into technical details.

Title explanation ASP. NET Core 1.0 labels ¶

ASP. NET Core 1.0 isCross-platformAndOpen SourceIs used to develop the website/Web API framework, formerly known as ASP. NET 5 (also known as ASP. NET vNext), but not ASP.. NET 4.6 Is an upgraded version from scratch.

ASP. NET Core 1.0 splits all functions and modules and completely decouples them. The source code can be found on Github ASP. NET.

Container ¶

Container technology is a virtualization technology. Unlike virtual machines, container technology does not provide an entire operating system. It can only provide an isolated running environment; container technology consumes much less system resources than virtual machines.

Docker is an open-source application container engine that does not need to change the kernel. It mainly uses the kernel features of the operating system to achieve virtualization, and all containers run in the same kernel.

Annotation

All containers run in the same kernel, which means that all containers must match the Operating System. Windows containers cannot run on Linux directly.

Monkey tips ¶

MonkeyIs a Spanish wordmonoIn Spanish, this word also has a cute meaning.

What I want to express is the Mono Project.

Therefore, this article means: in 2016, create a Docker container containing the Mono runtime environment, and then start two instances so that they can run ASP. NET Core 1.0 programs for you.

Create a home for the monkey ¶

First, you need to install the running environment of Docker (Linux), which is the blue part in the figure.

Prompt

Docker is not only for Linux, but also for Windows (which is currently a preview). That is to say, you can install the following two images.

However, if Windows is used, the complete. NET Framework is generally used insteadmono.

  • Create Dockerfile
  • If you useyo aspnetYou already have the Dockerfile. Otherwise, you need to create a file named Dockerfile in the project directory.

    FROM microsoft/aspnet:1.0.0-rc1-update1COPY . /appWORKDIR /appRUN ["dnu", "restore"]EXPOSE 5000/tcpENTRYPOINT ["dnx", "-p", "project.json", "web"]

    Explain each line.

     
     
    • Since the Docker file system is layered, FROM indicates the basis of the current image, followed by a colon;
    • COPY Copies local files to Docker,.Indicates the current directory;
    • WORKDIR specifies the working directory;
    • RUN indicates to RUN a program, followed by parameters;
    • EXPOSE indicates exposing a port number of Docker so that the host can communicate with the container;
    • ENTRYPOINT specifies the entry point. The first entry is the program, followed by the parameter.
    • Build a project
    docker build .

    View the built IMAGE. The image id is the identifier of the built IMAGE.

    docker images

    Name the image

    docker tag {IMAGE ID} qinnz/wukong

    Tips

    An image is equivalent to a container negative. We can use an image to create many identical containers.

    Let us run ASP. NET Core program at the same time ¶

    Now that you have an image, you need to run it. Of course, you can run multiple instances (but you cannot bind the same port ).

    docker run --name monkey_king -d -p 80:5000 qinnz/wukongdocker run --name his_dobule -d -p 81:5000 {IMAGE ID}

    We are at the background (-dTwo instances are started (one is the real Monkey King and the other is the fake Monkey King), respectively. These two containers can be identified by Tag or image id) port 5000 of is mapped to port 80 and port 81 of the host machine.

    So far, we have created a Docker container that contains the Mono runtime environment and asked it to run the ASP. NET Core 1.0 program for you.

    More resource quota ¶

    ASP. NET official documentation

    Create and run an ASP. NET Core 1.0 website on Mac OS

    The. NET command line program created on Mac OS X accesses the database (using Entity Framework 7)

    Docker

    Docker documentation

    It is declared that Bing shennian has imprisoned the true and false Monkey King in the container to run ASP. NET Core 1.0, which was created by diligent children and licensed using the knowledge sharing signature-non-commercial use-the deduction of the 4.0 international license agreement.
    Usage beyond the authorization of this License Agreement can be obtained from the http://space.cnblogs.com/msg/send/qin-nz.

    Related Article

    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.