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.