I am trying to execute remote commands into a container, using Rancher API. I run the following command, and the outcome is a token id and a web socket url. The commands pass via array don’t work. I’ve tried using /bin/sh without success . Could anyone help me with that ?
Command :
curl -u “${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY}” -X POST -H ‘Accept: application/json’ -H ‘Content-Type: application/json’ -d ‘{“attachStdin”:false, “attachStdout”:false, “command”:[“service”, “apache-perl”, “stop”], “tty”:false}’ “$RANCHER_URL/v1/projects/1a5/containers/1i156/?action=execute”
Output:
{“id”:null,“type”:“hostAccess”,“links”:{},“actions”:{},“token”:"eyJhbGc…XXX,“url”:“ws://rancher:8080/v1/exec/”}