Fix for terminal window columns and rows mismatch inside the container

I have figured out a simple workaround to a problem that was driving me CRAZY with the Docker container. Whenever I run ./launcher enter app, the columns and rows of the shell session from inside the container never matched my terminal window (I use iTerm2). This would make any command of medium or greater length wrap onto the same line, which made it very difficult to use. Running queries was especially bad.

I found a little trick on GitHub from user arielpontes to fix this.

I still get this all the time running Docker on Mac. I realized that if I simply resize the terminal window after attaching to the container, the problem is fixed.

Very simple workaround that I never thought of doing. :man_facepalming: Hope this helps somebody else.

Source:

4 Likes

You mean that all I’ve needed to do is resize the window?

1 Like

Yup! Test it out and let me know if it works.

From another GitHub issue it looks like the launcher script could possibly be modified to send the columns and rows so you wouldn’t need to resize:

https://github.com/moby/moby/issues/25450#issuecomment-354284254

1 Like

You have changed my life dramatically for the better.

I’ll add to my list submitting a PR to pass the size. It looks simple enough that I could do it. :wink:

docker run --rm -it -e COLUMNS=$COLUMNS -e LINES=$LINES -e TERM=$TERM -it ubuntu:16.04 tput lines
3 Likes