Multi-Stage Docker Build : Docker.DotNet.DockerApiException : Docker API responded with status code=Conflict #858
Replies: 2 comments 1 reply
-
AFAIK multi-stage works fine, we use it here.
Usually, the build context is not set correct (directory relative to the files required for the Docker build). See the following example: #610 (comment). Please make sure you pass the correct paths to the builder. If you still struggle with the configuration, can you please share your In addition you can set a custom logger ( |
Beta Was this translation helpful? Give feedback.
-
Here is my configuration
I already attached a Debugger, I briefly see a Container created with the Image I tagged in my Docker Desktop in a Running state but one weird thing happening now is the Test in VisualStudio never completes and the Log file keeps growing, I had to stop it. Here is a link to the logs https://pastebin.com/2uWFTtxN |
Beta Was this translation helpful? Give feedback.
-
I have a .Net Core 6 Project which I am trying to setup integration tests for using TestContainers.
I am using a Dockerfile generated by Visual Studio and this builds my image and I am able to run the container locally and the web api works as expected but when I run the same DockerFile in a TestContainers project I get the exception :
Docker.DotNet.DockerApiException : Docker API responded with status code=Conflict, response={"message":"Container 51d3ead2c1f194aef0c5876cbc29affe89c81c40b142131cd037e6eba8f5e624 is not running"}
Here is my Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /
COPY ./nuget.config /nuget.config
COPY ["MyProjectDir/MyProject.csproj", "MyProject/"]
COPY ["Common/Common.csproj", "Common/"]
RUN dotnet restore "MyProjectDir/MyProject.csproj"
COPY . .
WORKDIR "/MyProject"
RUN dotnet build "MyProject.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyProject.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyProject.dll"]
One thing I observed though is it seems the TestContainers instance is failing to run the final build stage of the Dockerfile as I only see the Publish Stage image when the process is completed and then get an exception.
Is there anything I am missing or is there an issue with Multi Container Builds?
Beta Was this translation helpful? Give feedback.
All reactions