Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error CTC1014 Docker command failed with exit code 1 with dotnet core api

I'm trying to build the most basic web Api application using VS2019 along with docker. Basically it is just the demo app provided by VS. I'm ending up with below error:

Severity Code Description Project File Line Suppression State Error CTC1014 Docker command failed with exit code 1. hcsshim::PrepareLayer - failed failed in Win32: Incorrec

Below my dockerfile

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-nanoserver-1903 AS base
WORKDIR /app
EXPOSE 8080
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1903 AS build
WORKDIR /src
COPY ["RegexTesterApi/RegexTesterApi.csproj", "RegexTesterApi/"]
RUN dotnet restore "RegexTesterApi/RegexTesterApi.csproj"
COPY . .
WORKDIR "/src/RegexTesterApi"
RUN dotnet build "RegexTesterApi.csproj" -c Release -o /app/build

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

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "RegexTesterApi.dll"]

Well this is the auto generated dockerfile. But it looks pretty ok to me (also I'm new to docker).

What is actually causing the error.

like image 530
Rahul Chakrabarty Avatar asked Feb 11 '20 16:02

Rahul Chakrabarty


1 Answers

I ran into the very same error (CTC1014) in the past. I found out that my project was being run in "Release" mode, when it should have been running in "Debug" mode. So I would like to suggest this as a workaround.

Here's how you change it in VS2019

Of course, running your application in Release mode shouldn't be a problem. So I assumed it must have been related to some optimization employed by most release build configurations, in conflict with Docker. Not exactly sure which one, though.

Cheers! o/

like image 67
Rodrigo Avatar answered Sep 20 '22 12:09

Rodrigo