diff --git a/api.go b/api.go index 771242fb2d..c661cc22b3 100644 --- a/api.go +++ b/api.go @@ -564,6 +564,13 @@ func ListenAndServe(addr string, srv *Server) error { r.Path(localRoute).Methods(localMethod).HandlerFunc(func(w http.ResponseWriter, r *http.Request) { Debugf("Calling %s %s", localMethod, localRoute) log.Println(r.Method, r.RequestURI) + + if strings.Contains(r.Header.Get("User-Agent"), "Docker-Client/") { + userAgent := strings.Split(r.Header.Get("User-Agent"), "/") + if len(userAgent) == 2 && userAgent[1] != VERSION { + Debugf("Warning: client and server don't have the same version (client: %s, server: %s)", userAgent[1], VERSION) + } + } json, err := localFct(srv, w, r) if err != nil { httpError(w, err) diff --git a/commands.go b/commands.go index c08c20b861..b63d23213b 100644 --- a/commands.go +++ b/commands.go @@ -28,31 +28,8 @@ var ( GIT_COMMIT string ) -func checkRemoteVersion() error { - body, _, err := call("GET", "/version", nil) - if err != nil { - return fmt.Errorf("Can't connect to docker daemon. Is 'docker -d' running on this host?") - } - - var out ApiVersion - - err = json.Unmarshal(body, &out) - if err != nil { - Debugf("Error unmarshal: body: %s, err: %s\n", body, err) - return err - } - if out.Version != VERSION { - fmt.Fprintf(os.Stderr, "Warning: client and server don't have the same version (client: %s, server: %)", VERSION, out.Version) - } - return nil -} - func ParseCommands(args ...string) error { - if err := checkRemoteVersion(); err != nil { - return err - } - cmds := map[string]func(args ...string) error{ "attach": CmdAttach, "build": CmdBuild, @@ -1177,6 +1154,7 @@ func call(method, path string, data interface{}) ([]byte, int, error) { if err != nil { return nil, -1, err } + req.Header.Set("User-Agent", "Docker-Client/"+VERSION) if data != nil { req.Header.Set("Content-Type", "application/json") } else if method == "POST" { @@ -1184,6 +1162,9 @@ func call(method, path string, data interface{}) ([]byte, int, error) { } resp, err := http.DefaultClient.Do(req) if err != nil { + if strings.Contains(err.Error(), "connection refused") { + return nil, -1, fmt.Errorf("Can't connect to docker daemon. Is 'docker -d' running on this host?") + } return nil, -1, err } defer resp.Body.Close()