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

后端 未结 3 833
慢半拍i
慢半拍i 2020-12-29 05:19

On my own PC the application runs nice, but when it gets deployed into docker, it fails because of invalid characters.

I am using the ubuntu:lastest con

3条回答
  •  难免孤独
    2020-12-29 05:53

    You need to set the locale correct.

    This is the minimal correct Dockerfile:

    FROM ubuntu:latest
    
    RUN locale-gen en_US.UTF-8
    ENV LANG en_US.UTF-8
    ENV LANGUAGE en_US:en
    ENV 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:

    • http://jaredmarkell.com/docker-and-locales/
    • https://github.com/docker-library/python/issues/13

提交回复
热议问题