Encoding Problems when running an app in docker (Python, Java, Ruby, ...) with Ubuntu Containers (ascii, utf-8) Encoding Problems when running an app in docker (Python, Java, Ruby, ...) with Ubuntu Containers (ascii, utf-8) python python

Encoding Problems when running an app in docker (Python, Java, Ruby, ...) with Ubuntu Containers (ascii, utf-8)


You need to set the locale correct.

This is the minimal correct Dockerfile:

FROM ubuntu:latestRUN locale-gen en_US.UTF-8ENV LANG en_US.UTF-8ENV LANGUAGE en_US:enENV LC_ALL en_US.UTF-8

The usual docker images don't specify a locales. You see it if you bash into it and execute locale:

sudo docker exec -i -t yowsup3 bash

Sources:


I tried the above solution and found that the locale-gen command is not available inside my docker.

so add this line above the RUN command or add it in.

RUN apt-get update && apt-get install -y locales && locale-gen en_US.UTF-8

this will now work.

and second ENV LC_ALL en_US.UTF-8 is enough to set most of the variable but it left with the two vacant so that's why we need all 3 to set.


FROM centos:7 ENV LANG=en_US.UTF-8

Adding the above one line in docker file worked for me