I use command: docker run --rm -it govim bash -l
to run docker images but
it does not display color output. If I source ~/.bash_profile
or run bash -l
again, output will then correctly be output with color.
相关问题
- How to get the return code of a shell script in lu
- Docker task in Azure devops won't accept "$(pw
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- JQ: Select when attribute value exists in a bash a
Based on @VonC's answer I adding the following to my Dockerfile (which allows me to run the container without typing the environment variables on the cli every time) :
and sure enough it works with:
For
tmux
to work with color, in my~/.tmux.conf
I need:and for
utf8
support intmux
, in my~/.bashrc
:My Dockerfile:
The Dockerfile builds an image based off Fedora 26, updates it, installs a few packages (git, vim, golang and tmux),installs the pathogen plugin for vim, then it installs a git repo from here vim-go-ide and finally does a few tweaks to a few config files to get color and utf8 working fine. Just need to add persistent storage, probably mounted under /app/go.
If you have an image with all the development tools already installed, just make a
Dockerfile
withENV
statement and add the commands to modify the config files in aRUN
statement without the installation commands and use your base image in theFROM
statement. I prefer this solution because I'm lazy and (besides the initial setup) it saves typing when you want to run the image.Using vim and plugins within tmux
Adding to VonC's answer, I made this bash function:
The OP SolomonT reports that
docker run
withenv
do work:And Fernando Correia adds in the comments:
As chepner commented (earlier answer),
.bash_profile
is sourced (itis an interactive shell), sincebash_prompt
is called by.bash_profile
.But docker issue 9299 illustrates that
TERM
doesn't seem to be set right away, forcing the users to open another bash with:You have similar color issues with issue 8755.
To illustrate/reproduce the problem:
The current workaround is :
Both are supposing you have a running container first, which might not be convenient here.
I think this is something that you'd have to implement manually. My container has python, so here's how I print in color using a single line:
example docker file:
standard terminal: