|
@@ -444,10 +444,10 @@ func (s *Server) postContainersAttach(ctx context.Context, w http.ResponseWriter
|
|
if vars == nil {
|
|
if vars == nil {
|
|
return fmt.Errorf("Missing parameter")
|
|
return fmt.Errorf("Missing parameter")
|
|
}
|
|
}
|
|
|
|
+ containerName := vars["name"]
|
|
|
|
|
|
- cont, err := s.daemon.Get(vars["name"])
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
|
|
+ if !s.daemon.Exists(containerName) {
|
|
|
|
+ return derr.ErrorCodeNoSuchContainer.WithArgs(containerName)
|
|
}
|
|
}
|
|
|
|
|
|
inStream, outStream, err := hijackServer(w)
|
|
inStream, outStream, err := hijackServer(w)
|
|
@@ -472,7 +472,7 @@ func (s *Server) postContainersAttach(ctx context.Context, w http.ResponseWriter
|
|
Stream: boolValue(r, "stream"),
|
|
Stream: boolValue(r, "stream"),
|
|
}
|
|
}
|
|
|
|
|
|
- if err := s.daemon.ContainerAttachWithLogs(cont, attachWithLogsConfig); err != nil {
|
|
|
|
|
|
+ if err := s.daemon.ContainerAttachWithLogs(containerName, attachWithLogsConfig); err != nil {
|
|
fmt.Fprintf(outStream, "Error attaching: %s\n", err)
|
|
fmt.Fprintf(outStream, "Error attaching: %s\n", err)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -486,10 +486,10 @@ func (s *Server) wsContainersAttach(ctx context.Context, w http.ResponseWriter,
|
|
if vars == nil {
|
|
if vars == nil {
|
|
return fmt.Errorf("Missing parameter")
|
|
return fmt.Errorf("Missing parameter")
|
|
}
|
|
}
|
|
|
|
+ containerName := vars["name"]
|
|
|
|
|
|
- cont, err := s.daemon.Get(vars["name"])
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
|
|
+ if !s.daemon.Exists(containerName) {
|
|
|
|
+ return derr.ErrorCodeNoSuchContainer.WithArgs(containerName)
|
|
}
|
|
}
|
|
|
|
|
|
h := websocket.Handler(func(ws *websocket.Conn) {
|
|
h := websocket.Handler(func(ws *websocket.Conn) {
|
|
@@ -503,7 +503,7 @@ func (s *Server) wsContainersAttach(ctx context.Context, w http.ResponseWriter,
|
|
Stream: boolValue(r, "stream"),
|
|
Stream: boolValue(r, "stream"),
|
|
}
|
|
}
|
|
|
|
|
|
- if err := s.daemon.ContainerWsAttachWithLogs(cont, wsAttachWithLogsConfig); err != nil {
|
|
|
|
|
|
+ if err := s.daemon.ContainerWsAttachWithLogs(containerName, wsAttachWithLogsConfig); err != nil {
|
|
logrus.Errorf("Error attaching websocket: %s", err)
|
|
logrus.Errorf("Error attaching websocket: %s", err)
|
|
}
|
|
}
|
|
})
|
|
})
|