2
4

More than 3 years have passed since last update.

RとPythonのDocker作業環境の構築2: 日本語対応

Posted at

はじめに

先日に以下の記事を投稿し,RとPythonが使える環境を構築するDockerfileを紹介しました。

RとPythonのDocker作業環境の構築

こちらの記事のDockerfileでは,以下の問題がありました。

  • 日本語の対応ができていない
  • 文字コードが異なっており,他OSのテキスト解析の結果を再現できない

そこで,localeを変更することで,上記問題を解決するDockerfileに修正しました。

FROM ubuntu:18.04

# set timezone
RUN apt-get update \
    && apt-get install tzdata \
    && ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
RUN date

# install packages
RUN ["/bin/bash", "-c", "\
    apt-get update \
    && apt-get install -y \
    vim \
    build-essential \
    git curl llvm sqlite3 libssl-dev libbz2-dev \
    libreadline-dev libsqlite3-dev libncurses5-dev \
    libncursesw5-dev python-tk python3-tk tk-dev aria2 \
    lsb-release locales\
    "]

RUN locale-gen ja_JP.UTF-8  
ENV LANG ja_JP.UTF-8  
ENV LANGUAGE ja_JP:ja
ENV LC_ALL ja_JP.UTF-8

RUN ["/bin/bash", "-c", "apt-get install -y software-properties-common"]
RUN apt-add-repository ppa:ansible/ansible -y
# install r
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
#RUN add-apt-repository 'deb https://cran.rstudio.com/bin/linux/ubuntu $(lsb_release -cs)-cran35/'
RUN add-apt-repository 'deb https://cran.rstudio.com/bin/linux/ubuntu bionic-cran35/'
RUN ["/bin/bash", "-c", "\
    apt-get update \
    && apt-get install -y r-base \
    "]
RUN Rscript --version
CMD ["/bin/bash", "-c"]

差分は以下の通りです。

  • python3.8 python3-pip のインストールをやめた
  • インストールするパッケージにlocalesを追加した
  • locale-genから始まるブロックで,日本語に設定した

以上です。
コンテナ上でpyenvを構築するためのスクリプトを作成中で,これができたらとりあえずPCを変えても再現できる環境が作れるのではないかと思っています。
スクリプトができたらまた記事書きます。

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4