Docker Compose has https issues but Docker Build runs fine

Viewed 69

I have this API that I want to run on Docker called AppONE.Api

When I run this command:

docker build -f APPONE.Api\Dockerfile --force-rm -t appone-api .

docker rm --force appone-api

docker run -d -p 8181:80 --name appone-api appone-api

I am able to run and start the container without any issue.

However, when I run compose:

docker-compose up --force-recreate --build -d

docker image prune -f

I get this error:

Unhandled exception. System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.

To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.

For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.

at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)

at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions)

at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)

at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)

at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)

at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)

at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)

at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)

at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)

at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)

at APPONE.Api.LocalEntryPoint.Main(String[] args) in /src/APPONE.Api/LocalEntryPoint.cs:line 16

The strange part is that I have another project with 4 containers inside that is running just fine. The docker compose and docker files are similar however this is the only project that gets this error.

This is the docker compose file:

version: '3.4'

services:
  appone.api:
    image: ${DOCKER_REGISTRY-}apponeapi
    build:
      context: .
      dockerfile: APPONE.Api/Dockerfile
    networks: 
    - ${NETWORK}
    ports:
    - "59529:443"
    - "59530:80"

networks:
  dev-network:
      name: ${NETWORK}

This is the Docker file inside the project:

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
#Add the nuget line if building locally
COPY ["NuGet.Config", "."]
COPY ["APPONE.Api/APPONE.Api.csproj", "APPONE.Api/"]
COPY ["APPONE.ClassLibrary/APPONE.ClassLibrary.csproj", "APPONE.ClassLibrary/"]
RUN dotnet restore "APPONE.Api/APPONE.Api.csproj"
COPY . .
WORKDIR "/src/APPONE.Api"
RUN dotnet build "APPONE.Api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "APPONE.Api.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "APPONE.Api.dll"]
0 Answers
Related