mirror of https://github.com/docker/docs.git
fix exec -d
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
ddf4d50bb6
commit
26785556fa
|
@ -552,6 +552,14 @@ func getEvents(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
c.eventsHandler.Wait(r.RemoteAddr, until)
|
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
|
// POST /containers/{name:.*}/exec
|
||||||
func postContainersExec(c *context, w http.ResponseWriter, r *http.Request) {
|
func postContainersExec(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
name := mux.Vars(r)["name"]
|
name := mux.Vars(r)["name"]
|
||||||
|
|
|
@ -71,7 +71,7 @@ var routes = map[string]map[string]handler{
|
||||||
"/containers/{name:.*}/attach": proxyHijack,
|
"/containers/{name:.*}/attach": proxyHijack,
|
||||||
"/containers/{name:.*}/copy": proxyContainer,
|
"/containers/{name:.*}/copy": proxyContainer,
|
||||||
"/containers/{name:.*}/exec": postContainersExec,
|
"/containers/{name:.*}/exec": postContainersExec,
|
||||||
"/exec/{execid:.*}/start": proxyHijack,
|
"/exec/{execid:.*}/start": postExecStart,
|
||||||
"/exec/{execid:.*}/resize": proxyContainer,
|
"/exec/{execid:.*}/resize": proxyContainer,
|
||||||
"/volumes": postVolumes,
|
"/volumes": postVolumes,
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,7 +12,7 @@ function teardown() {
|
||||||
swarm_manage
|
swarm_manage
|
||||||
docker_swarm create --name test_container busybox sleep 100
|
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
|
run docker_swarm exec test_container ls
|
||||||
[ "$status" -ne 0 ]
|
[ "$status" -ne 0 ]
|
||||||
[[ "$output" == *"is not running"* ]]
|
[[ "$output" == *"is not running"* ]]
|
||||||
|
@ -26,3 +26,22 @@ function teardown() {
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ "$output" == "foobar" ]
|
[ "$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 ]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue