当我运行时

docker run -i -t python /bin/bash

结果终端没有颜色。

我查看了以下链接,但它们没有帮助:

Docker bash prompt not display color

https://groups.google.com/forum/#!topic/docker-user/Bp4BaWRw6k4

https://github.com/docker/docker/issues/9299

我正在使用Windows 10上Docker工具箱中的Docker Quickstart Terminal。我有docker版本1.12.0,内部版本8eab29e。

最佳答案

要解决此问题,您需要更新~/.bashrc文件。

添加这样的东西(从默认的Ubuntu ~/.bashrc文件借来的)应该可以解决问题:

if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi

更新~/.bash文件后,您需要通过运行source ~/.bashrc重新加载该文件。

您可能需要创建自己的dockerfile,该文件会自动执行此操作。

10-04 10:34
查看更多