dotnet / Docker.DotNet

:whale: .NET (C#) Client Library for Docker API
https://www.nuget.org/packages/Docker.DotNet/
MIT License
2.26k stars 381 forks source link

Docker.DotNet fails to pull images with Docker Desktop 4.13.0 #595

Open HofmeisterAn opened 2 years ago

HofmeisterAn commented 2 years ago

Output of dotnet --info:

.NET SDK (reflecting any global.json):
 Version:   6.0.402
 Commit:    6862418796

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19044
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.402\

global.json file:
  Not found

Host:
  Version:      6.0.10
  Architecture: x64
  Commit:       5a400c212a

.NET SDKs installed:
  6.0.402 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

What version of Docker.DotNet?:

3.125.12

Steps to reproduce the issue:

// Given
var dockerClient = new DockerClientConfiguration().CreateClient();

// When
var pullImageTask = dockerClient.Images.CreateImageAsync(new ImagesCreateParameters { FromImage = "mysql:8.0.28" }, new AuthConfig(), null);

var exception = await Record.ExceptionAsync(() => pullImageTask)
  .ConfigureAwait(false);

// Then
Assert.Null(exception);

What actually happened?:

Xunit.Sdk.NullException
Assert.Null() Failure
Expected: (null)
Actual:   Newtonsoft.Json.JsonReaderException: Error parsing undefined value. Path '', line 1, position 2.
   at Newtonsoft.Json.JsonTextReader.MatchAndSetAsync(String value, JsonToken newToken, Object tokenValue, CancellationToken cancellationToken)
   at Newtonsoft.Json.JsonTextReader.ParseValueAsync(CancellationToken cancellationToken)
   at Docker.DotNet.Models.StreamUtil.MonitorStreamForMessagesAsync[T](Task`1 streamTask, DockerClient client, CancellationToken cancellationToken, IProgress`1 progress) in C:\Sources\GitHub\Docker.DotNet\src\Docker.DotNet\Endpoints\StreamUtil.cs:line 39
   at Docker.DotNet.Models.StreamUtil.MonitorResponseForMessagesAsync[T](Task`1 responseTask, DockerClient client, CancellationToken cancel, IProgress`1 progress) in C:\Sources\GitHub\Docker.DotNet\src\Docker.DotNet\Endpoints\StreamUtil.cs:line 51
   at Xunit.Record.ExceptionAsync(Func`1 testCode) in C:\Dev\xunit\xunit\src\xunit.core\Record.cs:line 76
   at Docker.DotNet.Tests.GitHub.Issue634() in C:\Sources\GitHub\Docker.DotNet\test\Docker.DotNet.Tests\GitHub.cs:line 22
   at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_1.<<InvokeTestMethodAsync>b__1>d.MoveNext() in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\Runners\TestInvoker.cs:line 264
--- End of stack trace from previous location ---
   at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\ExecutionTimer.cs:line 48
   at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in C:\Dev\xunit\xunit\src\xunit.core\Sdk\ExceptionAggregator.cs:line 90

What did you expect to happen?:

Additional information:

-

HofmeisterAn commented 2 years ago

For the example above the endpoint returns unknown image in /images/create?fromImage=mysql%3A8.0.28. It works if I set the image and tag separate from each other: new ImagesCreateParameters { FromImage = "mysql", Tag = "8.0.28" }. Neverless the Docker docs say:

Name of the image to pull. The name may include a tag or digest. This parameter may only be used when pulling an image. The pull is cancelled if the HTTP connection is closed.

HofmeisterAn commented 1 year ago

Probably relates to following update in 4.13.0 (might by working again in later releases):

Updated Docker Engine and Docker CLI to v20.10.20, which contain mitigations against a Git vulnerability, tracked in CVE-2022-39253, and updated handling of image:tag@digest image references, as well as a fix for CVE-2022-36109.