我像以前一样通过docker-compose运行具有重启策略的容器,它具有两个图像RabbitMq和AspNetCore,第一次都运行良好。
当我重新启动主机或docker容器时,即使重新启动后,RabbitMq也可以正常运行并且可以通过 localhost:8080 访问,但是aspnet核心项目容器正在运行,但是我无法通过内部和外部访问( localhost:5001 / api / home / get )端口。
Docker撰写
version: '3.4'
services:
aspnetcoreenvironmentvariables.api:
image: aspnetcoreenvironmentvariables
build:
context: .
dockerfile: AspNetCoreEnvironmentVariables.API/Dockerfile
restart: always
depends_on:
- rabbitmq
rabbitmq:
image: rabbitmq:3-management
restart: always
Docker撰写替代
version: '3.4'
services:
aspnetcoreenvironmentvariables.api:
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ConnectionStrings__DefaultConnection="connection"
ports:
- "5001:80"
rabbitmq:
ports:
- "8080:15672"