Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker.DotNet seems to return InternalServerError from Docker for all errors (even for 4** status codes) #266

Open
rvarna opened this issue Oct 18, 2017 · 5 comments

Comments

@rvarna
Copy link

rvarna commented Oct 18, 2017

I have been noticing that we always get InternalServerError from the docker daemon for any kind of issues. Today, I was trying to test out a case where we should be getting unauthorized, but we still end up getting InternalServerError.

Output of dotnet --info:
PS C:\windows\system32> dotnet --info
.NET Command Line Tools (2.0.2)

Product Information:
Version: 2.0.2
Commit SHA-1 hash: a04b4bf512

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

Microsoft .NET Core Shared Framework Host

Version : 2.0.0
Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

What version of Docker.DotNet?:
3.125

Steps to reproduce the issue:

  1. Try getting an image from a registry with invalid credentials.

Expected unauthorized but we still get InternalServerError.:
Docker.DotNet.DockerApiException: Docker API responded with status code=InternalServerError, response=
at Docker.DotNet.DockerClient.HandleIfErrorResponse(HttpStatusCode statusCode, String responseBody, IEnumerable1 handlers) at Docker.DotNet.DockerClient.<MakeRequestForStreamAsync>d__50.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Docker.DotNet.Models.StreamUtil.<MonitorStreamForMessagesAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()

However, Docker logs via
Get-EventLog -LogName Application -Source Docker -After (Get-Date).AddMinutes(-15) | Select Message produces

Handler for POST /v1.25/images/create returned error: unauthorized: authentication required
Attempting next endpoint for pull after error: unauthorized: authentication required
debug: Trying to pull myownrepo.azurecr.io/tanks2 from myownrepo.xcloudcr.azurecr.io v2

Looking at the code, I don't think this is a problem with Docker DotNet, but just wanted to check with the community here. It seems weird that docker would have one thing in the event log but return another. The docker API https://docs.docker.com/engine/api/v1.25/#operation/ImageCreate says we should get 4** status code

@SedarG
Copy link

SedarG commented Feb 1, 2018

I'm looking into this issue as well.

I do believe that this is a docker.dotnet client issue.
docker cli can print "unauthorized: authentication required" and so does the python client. The DockerApiException, on docker.dotnet, however, doesn't have this information. Here's the message of the exception that I observe:
Docker.DotNet.DockerApiException: 'Docker API responded with status code=InternalServerError, response='
It looks to me like the essential information got lost in translation.

@SedarG
Copy link

SedarG commented Feb 1, 2018

Here's what I see in debugger for what's being read from the named pipe:

HTTP/1.1 500 Internal Server Error
Api-Version: 1.35
Content-Length: 52
Content-Type: application/json
Date: Thu, 01 Feb 2018 08:26:49 GMT
Docker-Experimental: true
Ostype: windows
Server: Docker/17.12.0-ce (windows)
Connection: close

{"message":"unauthorized: authentication required"}.

@devcwm
Copy link

devcwm commented Oct 30, 2018

@SedarG Experiencing the same issue, not sure if you ever figured it out?

@jterry75
Copy link
Contributor

jterry75 commented Oct 30, 2018

What version of Docker.DotNet are you using? Our respond handler seems to handle this case on error by reading the body and assigning this to the DockerApiException message.

mdarocha pushed a commit to TrapTech/Docker.DotNet that referenced this issue Jul 11, 2022
… already exist.

SftpFileStream: In Append mode, create the remote file if it does not
already exist.
Fixes issue dotnet#266.
mdarocha pushed a commit to TrapTech/Docker.DotNet that referenced this issue Jul 11, 2022
… already exist.

SftpFileStream: In Append mode, create the remote file if it does not
already exist.
Fixes issue dotnet#266.
@NSTA2
Copy link

NSTA2 commented Jan 16, 2024

In case it helps someone else, I got this same (unhelpful) error when my docker file referenced a local image which hadn't yet been created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants