Radoslav Stoyanov
Radoslav Stoyanov

Reputation: 1710

Docker API - Exec start returns "Page not found"

I'm trying to execute a command in a running docker container through the Docker Engine API with cURL. I'm following the instructions in the API doc.
First I create an exec instance and as a response I receive the ID of the created exec.
Then I use the this ID when I try to send a request to start this exec, which looks as follows:

$ curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -x POST "http:/v1.29/exec/myExecID/start"

But the response from that request is:

{"message":"page not found"}

This is my Docker version:

Client:
 Version:      17.05.0-ce
 API version:  1.29
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:10:54 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.05.0-ce
 API version:  1.29 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:10:54 2017
 OS/Arch:      linux/amd64
 Experimental: false

In the code in the Moby's repository, they call the absolutely same address.

Anyone else faced this problem ever before? I'll be glad if you share your experience.

Upvotes: 0

Views: 2554

Answers (1)

Imam Digmi
Imam Digmi

Reputation: 458

Maybe it happens because you did not include the request body like this :

-d '{"Detach": false, "Tty": false}'

If you even get an error like below :

{"message":"No such exec instance '<ID>' found in daemon"}

That means you have not created an instance for exec. If so, you need to create a new instance

curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" \
-d '{"AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "DetachKeys": "ctrl-p,ctrl-q", "Tty": false, "Cmd": ["date"], "Env": ["FOO=bar", "BAZ=quux"]}' \
-X POST http:/v1.29/containers/fafe141c1a2b/exec

Output (example) :

{"Id":"70f08c296d460d2fe254ecd0f8e0416777a6b938bb74a325ffc76405d33d3526"}

After that then you can do exec as shown below :

curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" \
-d '{"Detach": false, "Tty": false}' \
-X POST http:/v1.29/exec/70f08c296d460d2fe254ecd0f8e0416777a6b938bb74a325ffc76405d33d3526/start

I've tried that way and it works, hopefully can help!

Upvotes: 1

Related Questions