nickj
nickj

Reputation: 100

Changing Locale in Docker Stops Many Commands From Executing?

How come when I change my locale in a Dockerfile using this...:

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

...so that I can achieve a change in locale from this...

LANG=  
LANGUAGE=  
LC_CTYPE="POSIX"  
LC_NUMERIC="POSIX"  
LC_TIME="POSIX"  
LC_COLLATE="POSIX"  
LC_MONETARY="POSIX"  
LC_MESSAGES="POSIX"  
LC_PAPER="POSIX"  
LC_NAME="POSIX"  
LC_ADDRESS="POSIX"  
LC_TELEPHONE="POSIX"  
LC_MEASUREMENT="POSIX"  
LC_IDENTIFICATION="POSIX"  
LC_ALL=  

..to this..

LANG=en_US.UTF-8  
LANGUAGE=en_US:en  
LC_CTYPE="en_US.UTF-8"  
LC_NUMERIC="en_US.UTF-8"  
LC_TIME="en_US.UTF-8"  
LC_COLLATE="en_US.UTF-8"  
LC_MONETARY="en_US.UTF-8"  
LC_MESSAGES="en_US.UTF-8"  
LC_PAPER="en_US.UTF-8"  
LC_NAME="en_US.UTF-8"  
LC_ADDRESS="en_US.UTF-8"  
LC_TELEPHONE="en_US.UTF-8"  
LC_MEASUREMENT="en_US.UTF-8"  
LC_IDENTIFICATION="en_US.UTF-8"  
LC_ALL=en_US.UTF-8 

Then I get issues, such as this with no commands executing:

root@820760edeb77:/# irb bash: irb: command not found

But if I take those changes to the locale, and leave them as they are after a rebuilt container, then everything works as expected??:

# ENV LANG en_US.UTF-8
# ENV LANGUAGE en_US:en
# ENV LC_ALL en_US.UTF-8

root@820760edeb77:/# irb 2.3.1 :001 >

I'm not too sure what would be causing this issue, whereby the changed locale inhibits commands from working, but suspect this could just be a side effect of such a change in Locale within the Docker container, and possibly not the real issue?

Upvotes: 1

Views: 656

Answers (1)

nickj
nickj

Reputation: 100

So I just figured it out, turns out I was using the wrong locale type for Docker, which is related to this issue here.

A small, but critical distinction C vs en_US:

WRONG

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

RIGHT

ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8
ENV LC_ALL C.UTF-8

Can anyone tell me why Docker uses C as a locale, vs en_US, or any other?

Now Ruby/irb is successfully working (albeit, with 4 hours of my life lost.....)

Upvotes: 2

Related Questions