У меня есть структура папок, как показано ниже:
[Services]
|
+--[IdentityService] (this folder contains Docker & docker-compose file)
|
+--[ProductService] (this folder contains Docker & docker-compose file)
|
+--[ApiGateway] (this folder contains Docker & docker-compose file)
|
+--docker-compose.yml
Вот мои разные файлы Docker:
1] ApiGateway - файл Docker
FROM microsoft/aspnetcore:2.0 AS base
WORKDIR /app
EXPOSE 9000
ENV ASPNETCORE_URLS=http://+:9000
FROM microsoft/aspnetcore-build:2.0 AS build
WORKDIR /src
COPY ["APIGateway.csproj", "./"]
RUN dotnet restore "./APIGateway.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "APIGateway.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "APIGateway.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
#ENTRYPOINT ["dotnet", "APIGateway.dll"]
ENTRYPOINT ["dotnet", "APIGateway.dll", "--server.urls", "http://0.0.0.0:9000"]
2] IdentityService - Dockerfile
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 9001
ENV ASPNETCORE_URLS=http://+:9001
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["WebApi.csproj", "./"]
RUN dotnet restore "./WebApi.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "WebApi.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "WebApi.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
#ENTRYPOINT ["dotnet", "WebApi.dll"]
ENTRYPOINT ["dotnet", "WebApi.dll", "--server.urls", "http://0.0.0.0:9001"]
3] ProductService - Dockerfile
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 9002
ENV ASPNETCORE_URLS=http://+:9002
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["Product.API.csproj", "./"]
RUN dotnet restore "./Product.API.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "Product.API.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "Product.API.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
#ENTRYPOINT ["dotnet", "Product.API.dll"]
ENTRYPOINT ["dotnet", "Product.API.dll", "--server.urls", "http://0.0.0.0:9002"]
И мой докер-compose.yml выглядит следующим образом: "
version: "3"
services:
api_gateway:
image: cog/mfp_api_gateway
build:
context: .
dockerfile: Services/ApiGateway/ApiGateway/Dockerfile
ports:
- "8082:9000"
depends_on:
- identity_service
- product_service
identity_service:
image: cog/mfp_identity_service
build:
context: .
dockerfile: Services/IdentityService/Dockerfile
ports:
- "8080:9001"
depends_on:
- db
product_service:
image: cog/mfp_product_service
build:
context: .
dockerfile: Services/ProductService/Dockerfile
ports:
- "8081:9002"
depends_on:
- db
db:
image: "mcr.microsoft.com/mssql/server:2017-latest"
environment:
SA_PASSWORD: "MYPASSWORD"
ACCEPT_EULA: "Y"
ports:
- "1433:1433"
volumes:
- ./.db:/var/opt/mssql/
- /var/opt/mssql/data
Здесь, когда я запускаю файлы Docker по отдельности, все создаются и работают правильно. Но когда я могу запустить внешний docker-compose.yml , я получаю ошибки, связанные с PATH. Нужно ли указывать относительный путь в docker-compose.yml файле?