1. Docker part:
First pull the latest asp.net core image:
docker pull microsoft/aspnetcore
Rename the downloaded image, why rename? I will explain it later when the registrator is introduced. Execute the following command:
docker tag microsoft/aspnetcore qkawebserver
Run docker, mount the local directory /apps/QkaWebServer to /apps/dotnet/ in the container, and map the two ports in the container, of which port 80 is the port of the website, and port 8800 is the port of the thrift service. Execute the following command:
docker run -ti -d --restart=always --privileged -v /apps/QkaWebServer:/apps/dotnet/ -v /etc/hosts:/etc/hosts -p:80 -p:8800 qkawebserver
To view all containers, execute the command:
docker ps -a
To run the .net core program and how to configure the daemon supervisor, please see a previous blog post http://www.cnblogs.com/focus-lei/p/6868324.html, and I won't go into details.
2. Consul part:
Download consul:
wget https://releases.hashicorp.com/consul/1.0.7/consul_1.0.7_linux_amd64.zip
Unzip:
unzip consul_1.0.7_linux_amd64.zip
run:
./consul agent -dev -ui -node=consul-dev -client=192.168.0.124
There is no clustering here, and the production environment will be considered again. Visit http://192.168.0.124:8500, you can visit to indicate that the installation was successful.
3. Registrator part
The inter-process communication in the Docker service is implemented through /var/run/docker.sock. The default service does not provide a listening port, so you need to manually bind the port to use the docker remote api.
vim /etc/systemd/system/docker.service
修改
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
The red part above is newly added. Restart the docker service after modification.
Pull the image of Registrator:
docker pull gliderlabs/registrator:latest
run:
docker run -d --name=registrator --net=host --volume=/var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator:latest consul://192.168.0.124:8500
Visit http://192.168.0.124:8500 again, and you can see that all the service addresses in docker are already available in services.