AI

Docker jupyter notebook 한글 관련

폼나게살자 2020. 2. 13. 14:41
반응형

Docker Container 만들기

command line에서 다음과 같이 실행합니다.

C:\>docker run -it -p 8888:8888 --name "container name" -e LANG=ko_KR.UTF-8 -v c:/users/user/documents/notebooks:/notebooks dash00/tensorflow-python3-jupyter

 

--name 뒤에 컨테이너 이름을 정하면 됩니다.

 

Container를 만들었으면 한글 패키지를 설치합니다.

C:\>docker start "container name"

C:\>docker exec -it "container name" /bin/bash

 

root@host:/notebooks# apt-get update
root@host:/notebooks# apt-get install locales
root@host:/notebooks# locale-gen ko_KR.UTF-8
root@host:/notebooks# locale -a

 

한글 폰트와 vi 입력기를 설치합니다.

root@host:/notebooks# apt-get install -y fonts-nanum fonts-nanum*

root@host:/notebooks# apt-get install vim

 

서울 Timezone도 설치합니다.

root@host:/notebooks# apt install tzdata

root@host:/notebooks# tzselect

4: Asia
23: Korea (South)
Asia/Seoul

root@host:/notebooks# ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime

 

jupyter에 암호를 설정합니다.

root@host:/notebooks# ipython
In [1]: from IPython.lib import passwd
In [2]: passwd()
Enter password: 
Verify password: 
'sha1:xxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
~/.jupyter/jupyter_notebook_config.py 파일에 아래 내용을 추가합니다.
c.NotebookApp.password = 'sha1:xxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

 

C:\>docker commit "container name"

 

matplotlib에서 한글 사용하기

---------------------------------------------------------------------------------------------------------

import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
from matplotlib import rc

#다음의 명령을 처음에만 실행하시면 됩니다.
fm._rebuild()

#
rc('font', family='NanumGothic')

plt.text(0.5, 0.5, ['한글', 'test'])
plt.show()

---------------------------------------------------------------------------------------------------------

 

반응형