mirror of https://github.com/docker/docs.git
Merge pull request #706 from jimmyxian/bug-fix-exec
bug fix: check status code in exec
This commit is contained in:
commit
92abcac33c
|
@ -325,6 +325,17 @@ func postContainersExec(c *context, w http.ResponseWriter, r *http.Request) {
|
|||
defer resp.Body.Close()
|
||||
defer closeIdleConnections(client)
|
||||
|
||||
// check status code
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 400 {
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
httpError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
httpError(w, string(body), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
httpError(w, err.Error(), http.StatusInternalServerError)
|
||||
|
|
|
@ -207,7 +207,15 @@ function teardown() {
|
|||
@test "docker exec" {
|
||||
start_docker 3
|
||||
swarm_manage
|
||||
run docker_swarm run -d --name test_container busybox sleep 100
|
||||
run docker_swarm create --name test_container busybox sleep 100
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
# if container is not runing, exec will failed
|
||||
run docker_swarm exec test_container ls
|
||||
[ "$status" -ne 0 ]
|
||||
[[ "$output" == *"is not running"* ]]
|
||||
|
||||
run docker_swarm start test_container
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
# make sure container is up and not paused
|
||||
|
|
Loading…
Reference in New Issue