Docker display isues in interactive termial mode

We have docker running on couple of ubuntu machines. When we try to run it in interactive shell mode, we face some weird behavior. Terminal has fixed size and long string input results in overwriting it cyclically. Here’s what it looks like:

user@e8800fc208de:/$ 
fffffffffffc208de:/$ fffffffffffffffffffffffffffffffffffffffffff 

mc also has fixed size. It seems that it depends on host system. We also have a couple of machines running arch, and docker works as we expect it to there.

Current docker version is 17.06. 17.03, 17.09 (both rc1 and rc2) demonstrate exactly the same behavior.
Host machines run ubuntu 14.04 and ubuntu 16.04. And flags we run it with are: --rm -it

Any ideas?