fix exec -d

Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
Victor Vieux 2015-10-01 01:59:14 -07:00
parent ddf4d50bb6
commit 26785556fa
3 changed files with 29 additions and 2 deletions

View File

@ -552,6 +552,14 @@ func getEvents(c *context, w http.ResponseWriter, r *http.Request) {
c.eventsHandler.Wait(r.RemoteAddr, until)
}
// POST /exec/{execid:.*}/start
func postExecStart(c *context, w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Connection") == "" {
proxyContainer(c, w, r)
}
proxyHijack(c, w, r)
}
// POST /containers/{name:.*}/exec
func postContainersExec(c *context, w http.ResponseWriter, r *http.Request) {
name := mux.Vars(r)["name"]

View File

@ -71,7 +71,7 @@ var routes = map[string]map[string]handler{
"/containers/{name:.*}/attach": proxyHijack,
"/containers/{name:.*}/copy": proxyContainer,
"/containers/{name:.*}/exec": postContainersExec,
"/exec/{execid:.*}/start": proxyHijack,
"/exec/{execid:.*}/start": postExecStart,
"/exec/{execid:.*}/resize": proxyContainer,
"/volumes": postVolumes,
},

View File

@ -12,7 +12,7 @@ function teardown() {
swarm_manage
docker_swarm create --name test_container busybox sleep 100
# if container is not running, exec will failed
# if container is not running, exec will fail
run docker_swarm exec test_container ls
[ "$status" -ne 0 ]
[[ "$output" == *"is not running"* ]]
@ -26,3 +26,22 @@ function teardown() {
[ "$status" -eq 0 ]
[ "$output" == "foobar" ]
}
@test "docker exec -d" {
start_docker_with_busybox 2
swarm_manage
docker_swarm create --name test_container busybox sleep 100
# if container is not running, exec will fail
run docker_swarm exec -d test_container ls
[ "$status" -ne 0 ]
[[ "$output" == *"is not running"* ]]
docker_swarm start test_container
# make sure container is up and not paused
[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]
run docker_swarm exec -d test_container echo foobar
[ "$status" -eq 0 ]
}