大家好。有人遇到过 consul 部署的问题吗?错误:“来自守护程序的错误 DT1001 错误响应:consul 清单:未找到最新版本:清单未知:清单未知如果错误仍然存在,请尝试重新启动 Docker Desktop。” 我用谷歌搜索了该错误,结果发现该图像已过时,他们建议将其更改consul
为hashicorp/consul
.
链接: https: //github.com/docker-library/docs/pull/2283
我采取的行动: 将 Dockerfile 中的行更改FROM consul
为FROM hashicorp/consul
/ FROM hashicorp/consul:latest
。我在控制台中运行了 docker-compose up 命令docker-compose build --no-cache. Перезапустил Docker Desktop. Запустил в консоли команду
。
它没有帮助并且显示相同的错误。
代码:
docker-compose.yml
version: "3.8"
services:
auth:
image: auth
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:5000
build:
context: ./
dockerfile: ./AuthService/Dockerfile
depends_on:
- auth_db
- elasticsearch
auth_db:
image: mongo
restart: always
volumes:
- ./AuthService/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
MONGO_INITDB_DATABASE: auth
notification:
image: notification_service
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:5000
build:
context: ./
dockerfile: ./NotificationService/Dockerfile
depends_on:
- notification_db
- consul-server
- elasticsearch
notification_db:
image: mongo
restart: always
volumes:
- ./NotificationService/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
MONGO_INITDB_DATABASE: notification_db
account:
image: account_service
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:5000
build:
context: ./
dockerfile: ./AccountService/Dockerfile
depends_on:
- account_db
- consul-server
- elasticsearch
account_db:
image: mongo
restart: always
volumes:
- ./AccountService/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
MONGO_INITDB_DATABASE: account_db
statistics:
image: statistics_service
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:5000
build:
context: ./
dockerfile: ./StatisticsService/Dockerfile
depends_on:
- statistics_db
- consul-server
- elasticsearch
statistics_db:
image: mongo
restart: always
volumes:
- ./StatisticsService/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
MONGO_INITDB_DATABASE: statistics_db
ocelot:
image: ocelot
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:5001;http://+:5000
volumes:
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
build:
context: .
dockerfile: ./OcelotService/Dockerfile
ports:
- "8000:5000"
- "8001:5001"
depends_on:
- ocelot_db
- consul-server
- elasticsearch
ocelot_db:
image: consul:latest
command: consul agent -dev -log-level=warn -ui -client=0.0.0.0
hostname: consul
ports:
- "8500"
elasticsearch:
image: elasticsearch:7.10.1
ports:
- "9200"
volumes:
- ${APPDATA}/ASP.NET/Volumes/Elastic:/usr/share/elasticsearch/data
environment:
- xpack.monitoring.enabled=true
- xpack.watcher.enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.type=single-node
kibana:
image: library/kibana:7.10.1
ports:
- "5601:5601"
depends_on:
- elasticsearch
environment:
- ELASTICSEARCH_URL=http://elasticsearch:9200
consul-server:
build:
context: .
dockerfile: ./Consul/Dockerfile
image: consul-server
restart: always
volumes:
- ./Consul/server.json:/consul/config/server.json:ro
- ./Consul/certs/:/consul/config/certs/:ro
command: "agent -bootstrap-expect=1 -client=0.0.0.0"
ports:
- "8500:8500"
- "8600:8600/tcp"
- "8600:8600/udp"
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- ./Prometheus:/etc/prometheus
- ${APPDATA}/ASP.NET/Volumes/Prometheus:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
ports:
- "9090:9090"
grafana:
image: grafana/grafana:latest
container_name: grafana
volumes:
- ${APPDATA}/ASP.NET/Volumes/grafana:/var/lib/grafana
- ./Grafana/provisioning/:/etc/grafana/provisioning
environment:
- GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}
- GF_USERS_ALLOW_SIGN_UP=false
ports:
- 3000:3000
docker-compose.dev.yml
version: "3.8"
services:
auth:
build: auth
ports:
- "27015:5000"
auth_db:
build: auth_db
ports:
- "27016:27017"
notification:
build: notification
ports:
- "29960:5000"
notification_db:
build: notification_db
ports:
- "29900:27017"
account:
build: account
ports:
- "28960:5000"
account_db:
build: account_db
ports:
- "27017:27017"
statistics:
build: statistics
ports:
- "29500:5000"
statistics_db:
build: statistics_db
ports:
- "29550:27017"
ocelot:
build: ocelot
ocelot_db:
build: ocelot_db
elasticsearch:
build: elasticsearch
kibana:
build: kibana
consul-server:
build: consul-server
ports:
- "8500:8500"
- "8600:8600/tcp"
- "8600:8600/udp"
领事/Dockerfile
FROM hashicorp/consul:latest
ENV CONSUL_KV_INIT_DIR=/var/local/consul-init.d
RUN mkdir -p $CONSUL_KV_INIT_DIR
COPY ./Consul/consul-init.sh /usr/local/bin/
RUN sed -ie 's|^\(set .*\)|\1\n/usr/local/bin/consul-init.sh \&|' /usr/local/bin/docker-entrypoint.sh
COPY ./Consul/init-configs/ $CONSUL_KV_INIT_DIR/
领事/consil-init.sh
set -ue
let "timeout = $(date +%s) + 15"
echo "==> Waiting for Consul"
while ! curl -f -s http://localhost:8500/v1/status/leader | grep "[0-9]:[0-9]"; do
if [ $(date +%s) -gt $timeout ]; then echo "==> Consul timeout"; exit 1; fi
sleep 1
echo "==> Waiting for Consul"
done
echo "==> Load configuration"
cd $CONSUL_KV_INIT_DIR
for json_file in $CONSUL_KV_INIT_DIR/**/*.json; do
key=$(basename "$json_file")
subprefix=$(basename $(dirname "$json_file"))
echo "==> Loading $key from $subprefix"
consul kv put "$subprefix/$key" @$json_file
done
图片: