[Docker] When terminal created from docker exec has strange behaviour (abnormal size, command vanishing, etc.)

less than 1 minute read

When I launch a docker container using ‘exec’ command inside tmux, sometimes I experience weird behaviour of terminal:

  1. The size of terminal within container is not the same as size of tmux pane.
  2. When I try to search for command history with upper arrow key, the searched command would not be displayed in the terminal.

Here is solution for the behaviour. I basically pass the size of terminal that a container should create.

docker exec -ti --env COLUMNS=`tput cols` --env LINES=`tput lines` junyonglee_tf /bin/zsh

Leave a Comment