`docker kill 123` will show something like:
`Error response from daemon: Cannot kill container 123: nosuchcontainer: No such container: 123`
Notice the `nosuchcontainer` text, that should not be there as that's an internal ID that means nothing to the end user.
This PR fixes this by using `util.GetErrorMessage()` to extract just the message.
While in that dir I found a couple of other spots that could use the same call, just to be safe.
Signed-off-by: Doug Davis <dug@us.ibm.com>
| ... | ... |
@@ -224,7 +224,7 @@ func (s *containerRouter) postContainersKill(ctx context.Context, w http.Respons |
| 224 | 224 |
// to keep backwards compatibility. |
| 225 | 225 |
version := httputils.VersionFromContext(ctx) |
| 226 | 226 |
if version.GreaterThanOrEqualTo("1.20") || !isStopped {
|
| 227 |
- return fmt.Errorf("Cannot kill container %s: %v", name, err)
|
|
| 227 |
+ return fmt.Errorf("Cannot kill container %s: %v", name, utils.GetErrorMessage(err))
|
|
| 228 | 228 |
} |
| 229 | 229 |
} |
| 230 | 230 |
|
| ... | ... |
@@ -462,7 +462,7 @@ func (s *containerRouter) wsContainersAttach(ctx context.Context, w http.Respons |
| 462 | 462 |
} |
| 463 | 463 |
|
| 464 | 464 |
if err := s.backend.ContainerWsAttachWithLogs(containerName, wsAttachWithLogsConfig); err != nil {
|
| 465 |
- logrus.Errorf("Error attaching websocket: %s", err)
|
|
| 465 |
+ logrus.Errorf("Error attaching websocket: %s", utils.GetErrorMessage(err))
|
|
| 466 | 466 |
} |
| 467 | 467 |
}) |
| 468 | 468 |
ws := websocket.Server{Handler: h, Handshake: nil}
|
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"github.com/docker/docker/api/server/httputils" |
| 12 | 12 |
"github.com/docker/docker/api/types" |
| 13 | 13 |
"github.com/docker/docker/pkg/stdcopy" |
| 14 |
+ "github.com/docker/docker/utils" |
|
| 14 | 15 |
"golang.org/x/net/context" |
| 15 | 16 |
) |
| 16 | 17 |
|
| ... | ... |
@@ -45,7 +46,7 @@ func (s *containerRouter) postContainerExecCreate(ctx context.Context, w http.Re |
| 45 | 45 |
// Register an instance of Exec in container. |
| 46 | 46 |
id, err := s.backend.ContainerExecCreate(execConfig) |
| 47 | 47 |
if err != nil {
|
| 48 |
- logrus.Errorf("Error setting up exec command in container %s: %s", name, err)
|
|
| 48 |
+ logrus.Errorf("Error setting up exec command in container %s: %s", name, utils.GetErrorMessage(err))
|
|
| 49 | 49 |
return err |
| 50 | 50 |
} |
| 51 | 51 |
|
| ... | ... |
@@ -112,7 +113,7 @@ func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.Res |
| 112 | 112 |
if execStartCheck.Detach {
|
| 113 | 113 |
return err |
| 114 | 114 |
} |
| 115 |
- logrus.Errorf("Error running exec in container: %v\n", err)
|
|
| 115 |
+ logrus.Errorf("Error running exec in container: %v\n", utils.GetErrorMessage(err))
|
|
| 116 | 116 |
} |
| 117 | 117 |
return nil |
| 118 | 118 |
} |