Docker bash prompt does not display color output

后端 未结 5 1215
闹比i
闹比i 2020-12-23 17:10

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

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-23 17:48

    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:

    FROM django:python3
    RUN python -c "print('\033[90m   HELLO_WORLD   \033[0m')"
    RUN python -c "print('\033[91m   HELLO_WORLD   \033[0m')"
    RUN python -c "print('\033[92m   HELLO_WORLD   \033[0m')"
    RUN python -c "print('\033[93m   HELLO_WORLD   \033[0m')"
    RUN python -c "print('\033[94m   HELLO_WORLD   \033[0m')"
    RUN python -c "print('\033[95m   HELLO_WORLD   \033[0m')"
    RUN python -c "print('\033[96m   HELLO_WORLD   \033[0m')"
    RUN python -c "print('\033[97m   HELLO_WORLD   \033[0m')"
    RUN python -c "print('\033[98m   HELLO_WORLD   \033[0m')"
    

    standard terminal:

提交回复
热议问题