Docker.DotNet
Docker.DotNet copied to clipboard
Handling errors when building image
Output of dotnet --info:
.NET SDK (reflecting any global.json):
Version: 6.0.100
Commit: 9e8b04bbff
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.15
OS Platform: Darwin
RID: osx.10.15-x64
Base Path: /usr/local/share/dotnet/sdk/6.0.100/
Host (useful for support):
Version: 6.0.0
Commit: 4822e3c3aa
.NET SDKs installed:
3.1.410 [/usr/local/share/dotnet/sdk]
5.0.103 [/usr/local/share/dotnet/sdk]
5.0.302 [/usr/local/share/dotnet/sdk]
6.0.100 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.16 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
What version of Docker.DotNet?:
3.125.5
Steps to reproduce the issue:
- Try building image with invalid syntax in Dockerfile using BuildImageFromDockerfileAsync method.
What actually happened?: BuildImageFromDockerfileAsync doesn't throw any exception. Instead, it ignores status code and reports everything to IProgress<JSONMessage> instance. When Dockerfile contains syntax errors, docker daemon responds with status code 400 and body which cannot be deserialized to JSONMessage (it contains only "message" field), so it's impossible to handle exceptions from building image.
What did you expect to happen?: BuildImageFromDockerfileAsync should throw exception if daemon responds with error.
And/Or, the JSONMessage needs to be updated to have a "message" field so that we can get the error from progress. Either way, can confirm that errors from Build and Create (and likely others) are basically being eaten. The only indication that anything went wrong was that nothing was return but a single hit to IProgress with an empty JSONMessage.
I don't think that updating JSONMessage is a good idea, because it's generated from Docker sources and should be in sync with it. Plus, it would be inconsistent way of exception handling if we consider other API methods.
@galvesribeiro We can close this issue.
@galvesribeiro , I'm still new on GitHub process here, so do you know who will trigger a new release build so that the fix can be available to the official nuget packages? 😀
Usually it depends how urgent the issue is. If it is not critical (like in this case) we probably collect some more fixes and publish them together. @galvesribeiro will do the release at some point.