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
docker
Verify 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