I am using Docker Remote API to run some commands, and I realised that the status is 200 even when the command I pass to it fails.
Example:
curl -H "Content-Type: application/json" -X POST -d '{"AttachStdin":false,"AttachStdout":true,"AttachStderr":true,"Tty":true,"Cmd":["wrong"]}' http://localhost:2375/containers/console/exec
This returns an Id.
curl -v -H "Content-Type: application/json" -d '{"Detach":false,"Tty":false}' http://localhost:2375/exec/b64592543bc59e08de4d1d11c8a68415148a608b00aa62448284635f47eaa734/start
POST /exec/b64592543bc59e08de4d1d11c8a68415148a608b00aa62448284635f47eaa734/start HTTP/1.1 Host: myip:2375 User-Agent: curl/7.47.1 Accept: / Content-Type: application/json Content-Length: 28
HTTP/1.1 200 OK Content-Type: application/vnd.docker.raw-stream exec: "wrong": executable file not found in $PATH
The status code is 200, so is there another way to know whether the command ran on exec succeeded?
My current workaround is to pass something like this as the command:
bash -c 'command && echo SUCCEEDED_FLAG || echo FAILED_FLAG'
and search for the flag later
PS: I used both postman and curl to test this.