The meaning of life is to explore the world

Ubuntu Docker container missing Chinese

Posted on By Jason Liu

  1. Ubuntu Docker container doesn’t have Chinese by default.
    Solution:
    • Option 1: install Chinese manually
        #Check locale
        locale -a
        #Check installed packages
        dpkg -l | less
      
        #Set environment variables LANG, and LC_ALL
        LANG='C.UTF-8'
        set |grep LANG
        LC_ALL='C.UTF-8'
        set |grep LC_ALL
        export LANG
        printenv |grep LANG
        export LC_ALL
        printenv |grep LC_ALL
      
    • Option 2: install it in Dockerfile
        RUN apt-get update
        RUN apt-get install -y locales
        ENV LANG C.UTF-8
        ENV LC_ALL C.UTF-8
      
  2. Failed to install locales.
     apt-get install -y locales
     E: Package 'locales' has no installation candidate
    

    Solution:
    Run apt-get update first