|
@@ -74,6 +74,16 @@ func (s *Server) getContainersStats(version version.Version, w http.ResponseWrit
|
|
|
}
|
|
|
|
|
|
stream := boolValueOrDefault(r, "stream", true)
|
|
|
+
|
|
|
+ // If the container is not running and requires no stream, return an empty stats.
|
|
|
+ container, err := s.daemon.Get(vars["name"])
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if !container.IsRunning() && !stream {
|
|
|
+ return writeJSON(w, http.StatusOK, &types.Stats{})
|
|
|
+ }
|
|
|
+
|
|
|
var out io.Writer
|
|
|
if !stream {
|
|
|
w.Header().Set("Content-Type", "application/json")
|