Hi,
I’m set out to execute simple commands in already running containers using the Rancher API and websockets.
All is good except that I can’t seem to find a way to read anything from stderr?
That is; issuing a execute request with the following payload will print my output through the websocket:
{
“tty”: false,
“command”: [
“/bin/bash”,
“-c”,
“echo derp”
]
}
This payload however will return nothing:
{
“tty”: false,
“command”: [
“/bin/bash”,
“-c”,
“>&2 echo derp”
]
}
I have tried to add attachStderr: true to the payload with no difference.
Though, the documentation hints nothing about that it should be doing anything so no great surprise there really…
I guess my actual question is this: what kind of workaround can I use for executing commands through the API and read both stdout and stderr and also be able to differantiate them from each other? (I can’t with TTY enabled)
When using the logs websocket I can simply regex my way out of the situation assuming TTY is disabled but I’m assuming some kind of rewrite of output is happening server-side for that?
I would be using the logs socket also for what I try to do here but can’t since the container is already running another command.
Thank you for all the awesomeness that is rancher btw!
It’s currently solving everything I need except cron-like scheduling and pipelining of several cron-like commands which is why I’m executing commands through the API in the first place.
(I’m writing a rancher plugin for rundeck but need stderr to get proper job states back in rundeck)
Anyways, thanks!
/ Klas