An explanation of how the ASP. NET core site runs in Docker

Source: Internet
Author: User
Tags connection reset docker ps docker run
This article mainly introduces the detailed description of the ASP. NET Core website running in Docker, very practical value, the need for friends can refer to the following

Docker as a new generation of virtualization, the future will certainly be widely used, the traditional virtual machine deployment way to ensure that the development environment, test environment, UAT environment, production environment dependence consistency, requires a large number of operations and maintenance of manpower, using Docker we can implement a deployment, run everywhere.

This article describes how to deploy an ASP. NET core site to run in Docker.

Software Environment Checklist

    1. CentOS 7.3.1611

    2. Docker 1.12.6

    3. . NET Core 1.1

Installing Docker

$ #安装Docker $ yum Install docker$ #启动docker服务 $ systemctl start docker.service$ #配置开机启动 $ systemctl Enable Docker.service

Configuring the Docker Accelerator

For well-known reasons, if you want to use Docker smoothly, you'll need to configure the Docker accelerator, or you'll feel like you're back in the dial-up internet era.
I use Daocloud, which is called permanent free. The registered address is: Https://account.daocloud.io/signin.

You can quickly complete your registration with a sweep.

Registration completion will provide a configuration script address:


$ #配置docker加速器 $ Curl-ssl https://get.daocloud.io/daotools/set_mirror.sh | Sh-s http://xxxxxx.m.daocloud.io$ #重启生效 $ systemctl Restart Docker

Pull the ASP. NET Core Image

$ docker Pull microsoft/aspnetcore$ #检查是否成功 $ docker Images

Preparing the ASP. NET core Web site publishing file

You can refer to my previous article: ASP. NET Core website published to Linux server

Create Dockerfile

To the Web site root directory, the file content is as follows:

From Docker.io/microsoft/aspnetcorecopy./publishworkdir/publish  EXPOSE 8080CMD ["Dotnet", " TestAspNetCoreWeb.dll "]

Package image

$ #注意最后有个点. $ docker build-t test-netcore:1.0.

Start container

$ docker Run--name test-netcore-p 8080:8080-d test-netcore:1.0$ #检查容器是否启动成功, if no effect after startup, try Docker run without D, if there is an error message. $ docker PS

The site is running successfully.

Report

The configuration process I encountered two scenarios in which the container failed to start:

1. The website listens to use the IP, the error "Error-99 Eaddrnotavail address Not available"

2. Web monitoring using localhost, error "Curl: (RECV) failure:connection reset by Peer"

Finally found the use of http://*:8080 to monitor the success.

The Docker run fails again after the prompt name already exists, you can use Docker Rm-f [container name] to remove the container or change the name.

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.