Fix for terminal window columns and rows mismatch inside the container

AI-generated summary

The discussion revolves around a solution for a terminal window columns and rows mismatch issue inside a Docker container. cmwebdev found a simple workaround: resizing the terminal window after attaching to the container fixes the problem. This trick was initially discovered by GitHub user arielpontes. pfaffman confirmed the solution and expressed gratitude, stating that it has significantly improved their experience.

It was also suggested that the launcher script could be modified to send the columns and rows, eliminating the need for manual resizing. pfaffman plans to submit a pull request to implement this solution.

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:
https://github.com/docker/compose/issues/253#issuecomment-361888888

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

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

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