Docker Community Forums

Share and learn in the Docker community.

Wrong colors inside Docker container

(Joe Sweeney) #1

I’m trying to setup a personal development environment inside a Docker container. I’m using iTerm 2 on macOS and the default “Dark Background” colors.

Outside of Docker, ls displays directories in light blue like it should. However, ls inside a docker container displays directories dark blue for some reason. I have already set $TERM=xterm-256color inside my container using an ENV line in my Dockerfile. I’ve verified this by echoing $TERM out inside the container as shown in the screenshots below.

I’m trying to figure out why the colors inside the container aren’t correct and how I can fix this.

I’m starting my container as follows: docker build -q -t jswny/devbox . && docker run -it -h devbox --name devbox jswny/devbox bash.

Here is my Dockerfile:

FROM ubuntu:18.04
RUN apt-get update

# Set environment variables
ENV TERM xterm-256color

# Install essentials
RUN apt-get install -y \
    make \
    cmake \
    git \

# Install user packages
RUN apt-get install -y \
    tmux \

# Change default shell to ZSH
RUN chsh -s $(which zsh)

# Install Oh My Zsh
RUN sh -c "$(curl -fsSL"

# Install asdf
RUN git clone ~/.asdf --branch v0.6.3
RUN echo -e '\n. $HOME/.asdf/' >> ~/.zshrc
RUN echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.zshrc
# RUN source ~/.zshrc

# Remove default .zshrc
RUN rm ~/.zshrc

# Add custom config files
ADD dotfiles /root/


# Override this as needed
CMD ["/usr/bin/zsh"]

Here is what ls looks like on my local machine:

And here is what it looks like inside my container:
Imgur link since I can’t upload two pictures to the same post :frowning:


(Gary Forghetti) #2

Those colors are determined by the LSCOLORS environment variable in your shell for iTerm2 on the Mac.

In Linux they are determined by the LS_COLORS environment variable.

Unfortunately the contents of those 2 variables are not interchangeable, so you have some work to do to make the Linux bash shell look the same.

(Joe Sweeney) #3

Thanks, those links are quite helpful! I will try to work with it. I realize now that the ls colors are not dependent on the color scheme of my terminal so I need to fix them inside the container.