mirror of https://github.com/docker/docs.git
commit
5f807caef1
|
@ -553,6 +553,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"]
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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 ]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue