dotnet / Docker.DotNet

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

Docker.DotNet hangs when attempting to pull an image to a remote host after extracting image completes #290

Open jon-swain-autocab opened 6 years ago

jon-swain-autocab commented 6 years ago

What version of Docker.DotNet?: 3.125.1

Steps to reproduce the issue:

  1. Connect to a docker daemon running on a remote host.
  2. Attempt to pull an image to that host using CreateImageAsync.
  3. Docker.DotNet hangs after extracting image completes and never returns.
  4. Image is not successfully pulled.

Additional information:

Remote host Windows 2016 server running docker version 17.06.2-ee-6.

NOTE. If you attempt to pull the image to docker running on the local machine it works correctly. (i.e. connect to http://localhost:2375)

The following code should be enough for you to reproduce the issue.

static async Task Main( string[] args )
{
    var IPOfRemoteHost = "PUT YOUR REMOTE HOST IP HERE";
    var PortOfRemoteHost = 2375;
    var image = "microsoft/dotnet-framework:4.7";

    using( var remoteClient = new DockerClientConfiguration( new Uri( $"http://{IPOfRemoteHost}:{PortOfRemoteHost}" ) ).CreateClient() )
    {
        var systemInfo = await remoteClient.System.GetSystemInfoAsync();

        Console.WriteLine( $"Connected to Docker Daemon @ {remoteClient.Configuration.EndpointBaseUri}" );
        Console.WriteLine( $"Daemon Version : {systemInfo.ServerVersion}{Environment.NewLine}" );

        Console.WriteLine( $"Attempting to pull image {image} to {remoteClient.Configuration.EndpointBaseUri}{Environment.NewLine}" );

        try
        {
            // create progress 
            var report = new Progress<JSONMessage>( msg =>
            {
                Console.WriteLine( $"{msg.Status}|{msg.ProgressMessage}|{msg.ErrorMessage}" );
            } );

            // pull image again
            await remoteClient.Images.CreateImageAsync( new ImagesCreateParameters
            {
                FromImage = image
            },
            new AuthConfig(),
            report
            );

            Console.WriteLine( $"{Environment.NewLine}Successfully pulled image {image} to {remoteClient.Configuration.EndpointBaseUri}" );
        }
        catch( Exception ex )
        {
            Console.WriteLine( $"Exception thrown attempting to pull image {image} to {remoteClient.Configuration.EndpointBaseUri}" );
            Console.WriteLine( $"{ex}" );
        }
    }

    Console.WriteLine( "Press ENTER to exit..." );
    Console.ReadLine();
}
stabiliser commented 6 years ago

I am seeing this issue as well, no exception is thrown and the thread appears to stall after it's finished extracting but the image does not appear in 'docker images'

jon-swain-autocab commented 6 years ago

Any update on this issue?

jterry75 commented 6 years ago

Hey @jon-swain-autocab. I wish I had good news. I have attempted to repro this now 10 times with tcp/http endpoints on a remote host and I don't ever see the hang. Can you run your application under a debugger and determine what the wait thread event is waiting on?

jterry75 commented 6 years ago

Correction. This doesn't repro for the base images. This does indeed repro for any image that isn't the base. Looking into this some more. Will update soon.

jon-swain-autocab commented 6 years ago

any timeline on when this will be fixed?