Prerequisite
64-bit, kernel 3.10 above, view current kernel version, open a terminal using UNAME-R to display your kernel version
??
??
??
Installation
sudo yum update
??
sudo tee/etc/yum.repos.d/docker.repo <<-' EOF '
[Dockerrepo]
Name=docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
Enabled=1
Gpgcheck=1
Gpgkey=https://yum.dockerproject.org/gpg
Eof
??
??
??
Installing Docker
sudo yum install docker-engine
??
??
Start Docker
sudo service docker start
??
Verify that Docker is installed properly
??
Installing a. NET Core image
https://hub.docker.com/r/microsoft/dotnet/
??
??
New File Dockerfile ?, and modify the content
??
??
File contents
#基于 ' Mcrosoft/dotnet:1.0.0-core ' to build our mirrors
From Microsoft/dotnet:1.0.0-core
??
#拷贝项目publish文件夹中的所有文件到 in the Publish folder in the Docker container
COPY. /publish
#设置工作目录为 '/publish ' folder, which is the container to start the default folder
??
Workdir/publish
??
#设置Docker容器对外暴露60000端口
EXPOSE 60000
??
#使用 ' dotnet MyApp.TestCore.dll ' to run the application
??
CMD ["Dotnet", "MyApp.TestCore.dll"]
??
??
??
??
Build image
Docker build-t My-dotnet-app.
??
Note that there was a.
If the creation fails, you need a VPN, this step I tried a few times there is always a timeout, I found a VPN to build it successfully
??
??
Run
Docker run--name my-dotnet-app-d-P 60000:60000 My-dotnet-app
??
Test Site
??
Failed, reported Curl: (RECV) failure:connection Reset by peer
??
Reference Solution: http://stackoverflow.com/questions/27806631/ Docker-rails-app-fails-to-be-served-curl-56-recv-failure-connection-reset
??
Modify the program as follows: Add Useconfiguration
var configuration = new Configurationbuilder ()
. Addcommandline (args)
. Build ();
??
var host = new Webhostbuilder ()
. Usekestrel ()
. Usecontentroot (Directory.GetCurrentDirectory ())
. Useconfiguration (Configuration)
. Useiisintegration ()
. Usestartup<startup> ()
. Build ();
??
Host. Run ();
??
Publishing programs
Modify Dockerfile ? file as follows
??
??
From Microsoft/dotnet:1.0.0-core
??
COPY. /publish
??
Workdir/publish
??
EXPOSE 5003
??
CMD ["Dotnet", "MyApp.TestCore.dll", "--server.urls", "http://*:5003"]
??
Rebuilding the Mirror
??
sudo docker build-t Dotnetapp.
??
??
Run and view
sudo docker run--name dotnetapp-d-P 5003:5003 Dotnetapp
??
??
Test Site
??
??
API returns data, successful
Firewall Open port
$ sudo firewall-cmd--zone=public--add-port=5003/tcp--permanent
$ sudo firewall-cmd--reload
??
??
The following problems are encountered:
1. The image was built because of network reasons, tried several times did not succeed, need to find a VPN
2.curl: (RECV) failure:connection reset by peer this error,. NET core created by default site binding is localhost this need to modify the site binding method by adding
Useconfiguration or Useurls way to modify bindings for the default site
??
??
??
??
??
??
Centos 7 ASP. NET Core 1.0 Docker Deployment