NET Core 2.0 in Docker on Windows Containers

Source: Internet
Author: User
Tags dotnet docker run

Installing Docker for Windows https://store.docker.com/editions/community/docker-ce-desktop-windows

To deploy an ASP. NET Core site to Docker, the first thing to do is to add Docker support, which is to build dockerfile in two ways, the first of which is when you create a new project

Another way is by right-clicking on the project → adding →docker support

This is the dockerfile generated after adding Docker support

From Microsoft/aspnetcore:2.0arg sourceworkdir/appexpose 80COPY  ${source:-obj/docker/publish}. entrypoint ["Dotnet", "WebApplication1.dll"]


Click this Docker button, if you do not have a local aspnetcore image will first pull this image, and then Webapplication1 this Web application bulid into a mirror (image), This time through the command to see there are two images (image) WebApplication1 and Microsoft/aspnetcore There is also a running container.

View container details by inspect

Docker Inspect 6fce4391165a

It is important to emphasize that the above dockerfile is not directly available in the build environment, and once you stop debugging in VS, the site will not be able to access, I have just that container as an interactive container do not know the right to understand, first delete the container and mirror just now.

Publish our application first, if publish to file system default should be Bin\release\publishoutpuy this path I will not change, click Publish. Copy the dockerfile from the root directory to the publish directory and modify it when the publication is complete

From Microsoft/aspnetcore:2.0workdir/appexpose 80COPY.  . entrypoint ["Dotnet", "WebApplication1.dll"]

Use the build command to create the image manually, open a command-line window under the Publish directory, and execute the following command

Docker build-t Webapp:dev.

Create two containers using a webapp image

Two instances have run and want to run a few more instances.
The above two IP is the IP of the container, usually the port of the container is mapped to the host port, with the host IP: port number to access, nginx or haproxy associated with each host: port number, so when creating the container will add the-p parameter

Docker Run-p 8080:80 Webapp:dev

NET Core 2.0 in Docker on Windows Containers

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.