set locale in 14.04 – Ask Ubuntu

I’m building a docker image based on Ubuntu 14.04 and am seemingly having troubles to set the locales correctly.

My Dockerfile looks like:

COPY .bashrc /root/.bashrc
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get install -y build-essential 
                       locales
RUN dpkg-reconfigure locales
WORKDIR /home/prs/

Where .bashrc is:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

it will build with no errors docker build -t "test" . but when I run it, I get the following output:

$ docker run -it test
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
root@d09247a538eb:/# source /root/.bashrc 
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
root@d09247a538eb:/# 

I also tried:

echo "LANG=en_US.UTF-8" > /etc/locale.conf

I still get:

# locale-gen
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

What’s going on with this? And how can the locale be set correctly?