CentOS utilizes Nginx+docker deployment. Netcore Application

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

Install Docker official documentation https://docs.docker.com/engine/installation/linux/docker-ce/centos/

[[email protected] ~]# Yum remove docker \ #删除旧版本

Docker-common \

Docker-selinux \

Docker-engine

- [[email protected] ~]# yum install y yum-utils \

\
  lvm2
\
--add-repo  \
Https://download.docker.com/linux/centos/docker-ce.repo
[[email protected] ~]# yum install docker-ce   #安装docker
[[email protected] ~]# systemctl start docker  #启动docker

dockerVerify that the hello-world installation is correct by running the image.

[[email protected] ~]# docker run hello-world

Configure Mirroring acceleration

Http://3e722983.m.daocloud.io
[[email protected] ~]# systemctl restart docker

Pull microsoft/dotnet Image

microsoft/dotnet
microsoft/microsoft/aspnetcore
Docker images

//启动一个dotnet镜像
//创建项目名为HelloDocker.Web.NET Core MVC项目
//进入HelloDocker.Web文件夹
//启动.NET Core MVC项目
 dotnet run

Mount host items into the container

To upload a project via FileZilla in the host demo directory:

Map 5000 port to host 5000 port and Mount host demo to container app directory based on Microsoft/dotnet:latest image

Docker run -p 5000:5000 -it -d -v /demo:/app microsoft/dotnet:latest
 
[[email protected] ~]# docker ps

[email protected]:/app/demo/SN_ITProjectSolution/WA_SNWeb# dotnet run

Test results

The external Access host IP 192.168.30.190:5000 automatically jumps to the Docker container 172.17.0.2:5000, indicating that the deployment was successful.

Via Nginx Load Balancer 80 Port Jump 5000 port

Installing nginx:http://blog.csdn.net/jenson_/article/details/77896608

Modify configuration file: vi/usr/local/nginx/conf/nginx.conf

To modify the Add code:

http {
    include       mime.types;
    default_type  application/octet-stream;
 
    #log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘
    #                  ‘$status $body_bytes_sent "$http_referer" ‘
    #                  ‘"$http_user_agent" "$http_x_forwarded_for"‘;
 
    #access_log  logs/access.log  main;
 
    sendfile        on;
    #tcp_nopush     on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
 
    #gzip  on;
     upstream 192.168.30.190 {
     server 192.168.30.190:5000 ;
 }
    server {
        listen       80;
        server_name  192.168.30.190;
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
        location / {
            root   html;
            index  index.html index.htm;
            proxy_pass http://192.168.30.190;
        }

Test results:

External Access 192.168.30.190 (the default 80 port) jumps to the 192.168.30.190:5000 port, 192.168.30.190:5000 is the mapped port of the Docker container 172.17.0.2:5000.

CentOS utilizes Nginx+docker deployment. Netcore Application

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.