ASP. NET core Development-docker deployment Run

Source: Internet
Author: User
Tags dotnet docker stop container docker ps docker run

ASP. NET Core develops a docker deployment, which supports Docker deployment operations. We run the ASP. NET Core deployment on Docker.

You may have seen Docker, and today we'll look at Docker's purpose and real-world scenarios.

Docker's application scenario from Paas,paas is the Docker scenario.

Platform as a services: platform as a service, is a service for software developers , cloud computing platform provides hardware, OS, programming language, development library, deployment tools, help software developers to develop software services faster. Google's Gae, for example.

Eight Docker real-world scenarios http://dockone.io/article/126

Top Benefits of Docker:

Static Packaging: Package the application and its runtime as a mirror;
Dynamic operation: Run the application as an application container.

We no longer have to care about what environment each system is installing, and directly copy the image to the system to run.

Once packaged, run directly.

Referring to Docker's logo, we can understand Docker as a whale container, and whales are the operating system.

Docker is a container that packs all the environment together and we just need to think about moving the container.

Let's start with the. NET Core Docker Tour.

Docker command:

Learn about Docker commands.

Docker images//Mirror ListDocker PS-A//all containers that have been runDocker Ps-l//Last Run ContainerDocker export Container ID> Documents//Persistence ContainerDocker import File//Import ContainerCat Export.tar| Docker import-linezero/demo-Export:latest Docker save image ID> Documents//Persistent MirroringDocker Load<file Docker RM container ID//Delete ContainerDocker RMI Image ID/Mirror Name//Remove MirrorDocker Run Image//Run

Tip: You can use Docker RM $ (Docker ps-q-a) to remove all the containers at once, and Docker RMI $ (Docker images-q) deletes all the mirrors at once.

ASP. NET Core runs on Docker

This article environment: Ubuntu 14.04 Docker for Linux 1.11.2

First we create an ASP. NET Core application.

dotnet NEW-T Web

Then add useurls ("http://*:5000") to the Program.cs

Publish dotnet Publish

We add dockerfile files to the Publish folder

From microsoft///tcpentrypoint ["dotnet"  "aspnetcore.dll"]

The final publish directory is as follows:

Copy the publish folder to the Ubuntu system

run the build command to build the Docker image.

Docker build-t Linezero/demo.

The following points are needed.

Then run the container

Docker Run-it-p 8080:5000 Linezero/demo

The relationship between the container and the mirror, a mirror can create multiple containers.

As above, I can create another Docker run-d-P 8090:5000 Linezero/demo

The-d parameter is also run in the background, and then through Docker PS you can see the state of the container running and stop with the Docker stop container ID.

Dockerfile Docker Container configuration file

Source Templates

From microsoft/dotnet:latestcopy./Appworkdir/Apprun ["dotnet","Restore"]run ["dotnet","Build"]expose the/Tcpentrypoint ["dotnet","Run"]

Post-Publish Template

From microsoft///tcpentrypoint ["dotnet"  "xx.dll"]

The above templates all depend on the microsoft/dotnet mirror, and the separately installed commands are

Docker Pull Microsoft/dotnet

It is also possible to install the build when it is not installed. The domestic speed may be somewhat slow, please wait patiently.

With the Docker dotnet image, you don't have to toss the Dotnet SDK installation, mirroring comes with.

If we want to put Docker on another machine, it's easy.

Save the image directly, then copy the mirror to the other machine, and then use the Docker command to load both.

Docker Save Linezero/demo > Demo.tar

And then load the command

Docker Load < Demo.tar

You can then run the program using Docker run without worrying about what dependencies the program requires.

If you think this article is helpful to you, please click " recommend ", thank you.

ASP. NET core Development-docker deployment Run

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.