济南市网站建设_网站建设公司_SQL Server_seo优化
2026/1/17 18:54:01 网站建设 项目流程

 

Remove all inactive dockers : docker container prune -f

Copy files in inactive docker to host server: docker container cp 5f9c2f1893c4:/app/migrator/ ./

VS.NET docker help

In CI pipeline, once the code were uploaded, the CI tool need to

pull the latest code and compile, then run the unit test

Use docker to generate docker image and save it locally

FROM microsoft/dotnet:2.2-aspnetcore-runtime
WORKDIR /app
COPY ./src/publish/ .
ENV ASPNETCORE_URLS http://*:5001
ENV ASPNETCORE_ENVIRONMENT docker
EXPOSE 5001
ENTRYPOINT dotnet Nanoservice.dll

Create Image : docker build . -t [tag]

Create Container : docker run -p 80:5001 --name nano5001 nanoservice2   #80 is the port id expose to internet, 5001 is the port host by docker

Stop the container : docker stop [containerId]

Get the log of container : docker logs [containerId]

Install docker compose

linkage 

Docker compose to spin up all sub components

[root@KubernateBox2 compose]# docker-compose -f Service.yml up -d

[root@KubernateBox2 compose]# docker-compose -f Service.yml down

version: "3.5"services:consul:image: consulcontainer_name: consulports:- 8500:8500networks:- dshop# network_mode: hostvolumes:- consul:/consul/datafabio:image: fabiolb/fabiocontainer_name: fabioenvironment:- FABIO_REGISTRY_CONSUL_ADDR=consul:8500networks:- dshop# network_mode: hostports:- 9998:9998- 9999:9999rabbitmq:image: rabbitmq:3-managementcontainer_name: rabbitmqports:- 5672:5672- 15672:15672networks:- dshop# network_mode: hostvolumes: - rabbitmq:/var/lib/rabbitmqjaeger:image: jaegertracing/all-in-onecontainer_name: jaegerports:- 5775:5775/udp- 5778:5778- 6831:6831/udp- 6832:6832/udp- 9411:9411- 14268:14268- 16686:16686networks:- dshop# network_mode: hostseq:image: datalust/seq container_name: seqenvironment:- ACCEPT_EULA=Yports:- 5341:80networks:- dshop# network_mode: hostvolumes: - seq:/datanetworks:dshop:name: dshop-networkexternal: truevolumes:consul:driver: localrabbitmq:driver: localseq:driver: local
Compose file

Create docker network to allows instance talk to each other

docker network create dshop-network

Spin up Product service

[root@KubernateBox2 ProductService]# docker run -p 5000:5000 --network dshop-network --name productservice productservice

[08:17:03 INF] Unable to connect to broker
Application startup exception: Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = IBusClient (DelegateActivator), Services = [RawRabbit.IBusClient], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> None of the specified endpoints were reachable (See inner exception for details.) ---> RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable ---> RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: No such device or address

Reason:hostname for rabbitmq at compose file is at upper case where it should be in lower case that match with rabbitmq container declaration 

Inspect the docker network

[root@KubernateBox2 ~]# docker network inspect  dshop-network
[{"Name": "dshop-network","Id": "760508b299392b2d5e1f4a394b193d8726e2709229cf3634fb12232bf4c518e8","Created": "2019-04-16T06:42:26.476264011Z","Scope": "local","Driver": "bridge","EnableIPv6": false,"IPAM": {"Driver": "default","Options": {},"Config": [{"Subnet": "172.18.0.0/16","Gateway": "172.18.0.1"}]},"Internal": false,"Attachable": false,"Containers": {"316598dc7379d4292865e75d1ddaab33325e75f70df88b1f104c446594617113": {"Name": "jaeger","EndpointID": "2f0dff994cf6fc6b8e5551956b7fd61c632d585e708af48cf4fecf6d7001688c","MacAddress": "02:42:ac:12:00:06","IPv4Address": "172.18.0.6/16","IPv6Address": ""},"3476a983803cde2ff02d66b7ddd95533f341c19698d1660d7bce5fb28bf3642c": {"Name": "consul","EndpointID": "68b9c84c3fc2cf4e0e36f630849e594de2b2dfb71dbfd9b972d408c6baac4bab","MacAddress": "02:42:ac:12:00:03","IPv4Address": "172.18.0.3/16","IPv6Address": ""},"3576047a0f2a4510b01bb09e43c7a101ad61fa449c7bc5301f64b7eeec26b067": {"Name": "rabbitmq","EndpointID": "d377b450ca2f066f0ff6f0913163856b57f802ad9749f71222c33b659ec2fc73","MacAddress": "02:42:ac:12:00:02","IPv4Address": "172.18.0.2/16","IPv6Address": ""},"4fb8adbcb0a1d268d662806719bb8a793da5450052869f51e18c34a185b3090b": {"Name": "seq","EndpointID": "0e82aa916519e526bddb60a6b6bbc656f8ed6889b3f032e1b7f2dd9b6e498691","MacAddress": "02:42:ac:12:00:05","IPv4Address": "172.18.0.5/16","IPv6Address": ""},"c65745fa6d9527758d18bbafe0df133631cc671382fb3b3d56e0f3f5538b7a71": {"Name": "productservice5000","EndpointID": "fec71dd2ac5ddd7df0b2d96c25b004ffe6ff7ab4e962e83b6cfae78cda022792","MacAddress": "02:42:ac:12:00:07","IPv4Address": "172.18.0.7/16","IPv6Address": ""},"c7fab7d3c406421925fca779f029d2758335b5744eb61d679518a657c7fa5226": {"Name": "fabio","EndpointID": "98a0049b0598516ab0845cae0c793e011ccac6041819d7e697f856ab4e3344cb","MacAddress": "02:42:ac:12:00:04","IPv4Address": "172.18.0.4/16","IPv6Address": ""}},"Options": {},"Labels": {}}
]
View json

Consul did not find the product srvice instance, attempt to get into docker container to change the docker.config.json without recompile the docker image

[root@KubernateBox2 ProductService]# docker exec -it productservice5000 /bin/bash

root@c65745fa6d95:/APP# nano appsettings.docker.json

After modificaiton, spin up the dll without leaving the docker container
root@c65745fa6d95:/APP# dotnet ProductService.dll

 User docker logs [ConstainerId] to check logs

 

VS.net docker help

Unable to find image 'hello-world:latest' locally
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.Solution
Right Klick Docker Icon and go to Docker Settings then Network Tab Change DNS from Automatic to Fixed and Check your Proxy Settings.

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询