如何让竖线在 docker 中的 tmux 运行 中正确显示?

how do I get vertical bars to show up properly in tmux running in docker?

我正在尝试在 docker 中使用 tmux。在大多数情况下,它工作正常,但如果我将我的主 window 分成左右 window,tmux 应该在两个 windows 之间绘制的条仅部分绘制。还有一些其他 window 渲染问题,但这是我注意到的第一个,也是最容易描述的问题。

这是我用来构建测试映像的 Dockerfile:

FROM ubuntu:wily

RUN apt-get update && apt-get install -y tmux 

这是我用 tmux 启动 docker 的命令:

sudo docker run -it --entrypoint tmux imageName

我的主机是 运行 Ubuntu 15.04,我是 运行 docker 来自带有 TERM=xterm 的终端。在 docker 容器内,TERM=screen

如果我启动 sshd 而不是 tmux,那么我可以使用 ssh 登录 运行 容器并在 ssh 会话中使用 tmux 而不会出现问题。这是我到目前为止一直在做的事情,但它似乎不必要地混乱。

我该怎么做才能让 windows 正确绘制。

tmux 项目上也有类似的问题 (issue 224)

解决方案是:

set -ag terminal-overrides ',*:cud1=\E[1B'

已添加到 .tmux.conf 文件中(例如 ~/.tmux.conf)。

您还有 docker/issues/8755,这是 运行 进行 tmux 会话时的正确 tty。

docker exec -ti $CONTAINER_NAME tty
not a tty

And again, the workaround:

docker exec -ti $CONTAINER_NAME script -qc 'tty' /dev/null
/dev/pts/0

最后,issue 5379提到:

with the env var set to screen-256color it worked. Couldn't find any other $TERM that did that trick though (tried some like xterm-256color).

这意味着 运行宁 docker 运行 带有 -e TERM=screen-256color 选项。