-
Notifications
You must be signed in to change notification settings - Fork 564
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
Error: "unexpected end of JSON input" from CreateNetwork() #845
Comments
@KIVagant can you share a reproducer? Are you sure the error is on the CresteNetwork call and not on the client instantiation? 🤔 |
About adding debug information, generally a library shouldn't touch stdout and stderr, what we need is a better error message with more context x) |
In my case the code is called by another tool, but the error appeared when I had an empty |
Gotcha. Yeah, CreateNetwork never tries to read .dockercfg, as that file contains auth configuration that's used to authenticate with the daemon or docker registries, something not required in the CreateNetwork call. For example, this succeeds:
But this would fail: package main
import (
"fmt"
docker "github.com/fsouza/go-dockerclient"
)
func main() {
authConfigs, err := docker.NewAuthConfigurationsFromDockerCfg()
if err != nil {
panic(err)
}
fmt.Println(authConfigs)
} |
I saw the error coming from |
How do you know the error was coming from |
I was able to configure a debugger the code and now I can confirm your assumption. This is a "stack trace" that produces the error:
|
This is the new latest version of the code: https://github.com/fsouza/go-dockerclient/blob/main/auth.go#L198
I guess a "if not empty" check could fix this. |
Yeah, I know the origin of the error, this is what I shared above. It's just not in the path of CreateNetwork, so I was wondering if something was off 🤔 Can definitely improve the error message. |
Hello. I'm getting the error from
network.CreateNetwork()
:I feel like it is produced by the line:
https://github.com/fsouza/go-dockerclient/blob/main/network.go#L181
I see how the network is being created in Docker, but I cannot get the proper response back from the function.
It would be nice to have a debug mode to check the actual response.
Package Version:
Docker version:
Update: I found what caused this specific issue (or more how to fix it):
Pretty funny that an empty
~/.dockercfg
prevents the network from being created. Anyway it would be nice to get a message printed tostderr
(at least in "debug" mode).The text was updated successfully, but these errors were encountered: