mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Update docs and test of exec create api return codes
Fixes issue #18054 Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
This commit is contained in:
parent
c32f8bb36a
commit
01b86d612c
4 changed files with 22 additions and 3 deletions
|
@ -108,7 +108,7 @@ func (d *Daemon) getExecConfig(name string) (*ExecConfig, error) {
|
||||||
ec := d.execCommands.Get(name)
|
ec := d.execCommands.Get(name)
|
||||||
|
|
||||||
// If the exec is found but its container is not in the daemon's list of
|
// If the exec is found but its container is not in the daemon's list of
|
||||||
// containers then it must have been delete, in which case instead of
|
// containers then it must have been deleted, in which case instead of
|
||||||
// saying the container isn't running, we should return a 404 so that
|
// saying the container isn't running, we should return a 404 so that
|
||||||
// the user sees the same error now that they will after the
|
// the user sees the same error now that they will after the
|
||||||
// 5 minute clean-up loop is run which erases old/dead execs.
|
// 5 minute clean-up loop is run which erases old/dead execs.
|
||||||
|
|
|
@ -2256,6 +2256,8 @@ Status Codes:
|
||||||
|
|
||||||
- **201** – no error
|
- **201** – no error
|
||||||
- **404** – no such container
|
- **404** – no such container
|
||||||
|
- **409** - container is paused
|
||||||
|
- **500** - server error
|
||||||
|
|
||||||
### Exec Start
|
### Exec Start
|
||||||
|
|
||||||
|
@ -2291,7 +2293,7 @@ Status Codes:
|
||||||
|
|
||||||
- **200** – no error
|
- **200** – no error
|
||||||
- **404** – no such exec instance
|
- **404** – no such exec instance
|
||||||
- **409** - container is stopped or paused
|
- **409** - container is paused
|
||||||
|
|
||||||
**Stream details**:
|
**Stream details**:
|
||||||
Similar to the stream behavior of `POST /container/(id)/attach` API
|
Similar to the stream behavior of `POST /container/(id)/attach` API
|
||||||
|
|
|
@ -2263,6 +2263,8 @@ Status Codes:
|
||||||
|
|
||||||
- **201** – no error
|
- **201** – no error
|
||||||
- **404** – no such container
|
- **404** – no such container
|
||||||
|
- **409** - container is paused
|
||||||
|
- **500** - server error
|
||||||
|
|
||||||
### Exec Start
|
### Exec Start
|
||||||
|
|
||||||
|
@ -2298,7 +2300,7 @@ Status Codes:
|
||||||
|
|
||||||
- **200** – no error
|
- **200** – no error
|
||||||
- **404** – no such exec instance
|
- **404** – no such exec instance
|
||||||
- **409** - container is stopped or paused
|
- **409** - container is paused
|
||||||
|
|
||||||
**Stream details**:
|
**Stream details**:
|
||||||
Similar to the stream behavior of `POST /container/(id)/attach` API
|
Similar to the stream behavior of `POST /container/(id)/attach` API
|
||||||
|
|
|
@ -49,6 +49,21 @@ func (s *DockerSuite) TestExecApiCreateNoValidContentType(c *check.C) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerSuite) TestExecApiCreateContainerPaused(c *check.C) {
|
||||||
|
testRequires(c, DaemonIsLinux)
|
||||||
|
name := "exec_create_test"
|
||||||
|
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
|
||||||
|
|
||||||
|
dockerCmd(c, "pause", name)
|
||||||
|
status, body, err := sockRequest("POST", fmt.Sprintf("/containers/%s/exec", name), map[string]interface{}{"Cmd": []string{"true"}})
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
c.Assert(status, check.Equals, http.StatusConflict)
|
||||||
|
|
||||||
|
if !bytes.Contains(body, []byte("Container "+name+" is paused, unpause the container before exec")) {
|
||||||
|
c.Fatalf("Expected message when creating exec command with Container %s is paused", name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestExecAPIStart(c *check.C) {
|
func (s *DockerSuite) TestExecAPIStart(c *check.C) {
|
||||||
dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top")
|
dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue