Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fin exec no-tty mode #144

Closed
lmakarov opened this issue Mar 9, 2017 · 2 comments · Fixed by #145
Closed

fin exec no-tty mode #144

lmakarov opened this issue Mar 9, 2017 · 2 comments · Fixed by #145

Comments

@lmakarov
Copy link
Member

lmakarov commented Mar 9, 2017

Output from fin exec cannot be used for string comparison directly.
This is due to docker exec spitting out \r\n line ending even on Mac. Additionally, on Windows a special hidden flag should be set for winpty to enable dumb terminal mode.

On Mac apply tr -d '[:cntrl:]'
On Windows apply winpty -Xplain and tr -d '[:cntrl:]'

@lmakarov
Copy link
Member Author

lmakarov commented Mar 9, 2017

Apparently the the \r\n sequence is only present when tty (-t) is used with docker run/exec

$ docker run --rm busybox pwd | od -c
0000000    /  \n                                                        
0000002

$ docker run --rm -t busybox pwd | od -c
0000000    /  \r  \n                                                    
0000003

The corresponding docker issue moby/moby#8513 (comment)

Moral of the story, don't use -t unless you want a TTY.
TTY line endings are CRLF, this is not Docker's doing.

We will still have to handle the case with Windows and winpty in fin exec.

@lmakarov
Copy link
Member Author

lmakarov commented Mar 9, 2017

On Windows

$ docker run --rm busybox pwd | od -c
0000000   /  \n
0000002
$ docker run --rm -i busybox pwd | od -c
0000000   /  \n
0000002
$ docker run --rm -t busybox pwd | od -c
0000000   /  \r  \n
0000003
$ docker run --rm -it busybox pwd | od -c
the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'
0000000

Now if we add winpty to the mix

$ winpty -Xallow-non-tty -Xplain docker run --rm busybox pwd | od -c
0000000   /  \r  \n
0000003
$ winpty -Xallow-non-tty -Xplain docker run --rm -i busybox pwd | od -c
0000000   /  \r  \n
0000003
$ winpty -Xallow-non-tty -Xplain docker run --rm -t busybox pwd | od -c
0000000   /  \r  \n
0000003
$ winpty -Xallow-non-tty -Xplain docker run --rm -it busybox pwd | od -c
0000000   /  \r  \n
0000003

Proposed flag for fin exec (similar to what docker-compose is doing):

    -T                Disable pseudo-tty allocation. By default `docker-compose exec`
                      allocates a TTY.

When set, -t on docker exec will not be set and winpty will not be used (on Windows).

@lmakarov lmakarov changed the title fin exec plain mode fin exec no-tty mode Mar 9, 2017
lmakarov added a commit that referenced this issue Mar 9, 2017
fin exec tty improvements

resolves #144, resolves #139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant