Docker Bash 没有颜色

cyc*_*tic 6 linux bash shell docker

当我跑

docker run -i -t python /bin/bash
Run Code Online (Sandbox Code Playgroud)

结果终端没有颜色。

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

Docker bash 提示不显示颜色

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

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

我在 Windows 10 上使用 Docker 工具箱中的 Docker 快速入门终端。我有 Docker 版本 1.12.0,构建 8eab29e。

小智 6

要解决此问题,您需要更新~/.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
Run Code Online (Sandbox Code Playgroud)

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

您可能想要创建自己的 dockerfile 来自动执行此操作。