3

Main Concerns

  • I use curl to run my requests. Running the requests with postman seems to not show much difference between TTY enabled or disabled.
  • Stderr shows with TTY enabled, but not with TTY disabled. AttachStderr is set to true for both (using curl).
  • Stdout is 'incomplete' with TTY enabled (using curl).

=========================================

I am struggling trying to figure out when to allocate a pseudo tty with Docker Remote API, and when not to. The output is very different (depending on whether there were errors, and other things I don't quite understand).

I am using curl to execute my requests.

Example:

No TTY:

# ls on a container
curl --unix-socket /var/run/docker.sock -s -H "Content-Type: application/json" -X POST -d  '{"AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "Tty": false, "Cmd": [ "ls" ] }' http:/containers/mycontainer/exec
curl --unix-socket /var/run/docker.sock -s -H "Content-Type: application/json" -X POST -d  '{"Detach": false, "Tty": true }' http:/exec/5b2a3882e04432180806deffd7d9417d9f75b439022bce16211c296beb158319/start

This outputs: bin boot dev etc exports home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var

Same commands with Tty: true output boot etc home lib64 mnt proc run srv tmp varsr

However, if I try to do something that creates an error:

No TTY:

# ls /non/existant/path
curl --unix-socket /var/run/docker.sock -s -H "Content-Type: application/json" -X POST -d  '{"AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "Tty": false, "Cmd": [ "ls", "/non/existant/path" ] }' http:/containers/mycontainer/exec
curl --unix-socket /var/run/docker.sock -s -H "Content-Type: application/json" -X POST -d  '{"Detach": false, "Tty": true }' http:/exec/11d9bff545d99e64bc1c82b540966e2cceaa48c98fbde851378cdb5de9cae663/start

Without TTY, I do not see any output.

With TTY: ls: cannot access '/non/existant/path': No such file or directory

What's going on?

Thank you.

Alberto Rivera
  • 3,652
  • 3
  • 19
  • 33
  • Hadn't you considered stdout/stderr are handled differently? Try running `ls path/that/exists/ >&2` as well... – agg3l Oct 29 '16 at 02:39
  • @agg3l You are right, if I redirect to stderr, I do not see any output with tty disabled. However, I thought AttachStderr would show it. Also, I have no idea why tty:true makes the output look weird. Lastly, I ran another command which had no stderr and was empty with tty:false. I will write it soon. – Alberto Rivera Oct 29 '16 at 02:43
  • Seems this effectively shifts question into _"why stdout is available without TTY, while stderr is not (both are there with TTY)"_... Not that I can answer your question immediately – agg3l Oct 29 '16 at 02:50
  • Yeah, but I would also like to know why is stdout with TTY different from stdout without TTY. – Alberto Rivera Oct 29 '16 at 02:53
  • I suggest you adjust your question and make an accent on specific issues you found so far, it's hard to read and compare wide lines you've pasted with naked eye – agg3l Oct 29 '16 at 03:00
  • Followed your suggestions. Thanks a lot. – Alberto Rivera Oct 29 '16 at 03:03

1 Answers1

0

I will respond my own question with everything that I know so far, in case someone sees this.

TTY basically will make the output "look" as it looks in a terminal. That is, if there are multiple folders (in my case), they should be displayed in two different lines.

I still do not know why I cannot see stderr with TTY disabled, but this is the reason I cannot see the full stdout with TTY enabled.

Alberto Rivera
  • 3,652
  • 3
  • 19
  • 33