docker 容器部署tomcat後,日誌文件中出現中文亂碼,不少問號,中文的文件夾也是問好。先看看容器的locale:docker
[root@docker1 ~]# docker exec -it 41de9a0b6045 locale LANG= LC_CTYPE="POSIX" LC_NUMERIC="POSIX" LC_TIME="POSIX" LC_COLLATE="POSIX" LC_MONETARY="POSIX" LC_MESSAGES="POSIX" LC_PAPER="POSIX" LC_NAME="POSIX" LC_ADDRESS="POSIX" LC_TELEPHONE="POSIX" LC_MEASUREMENT="POSIX" LC_IDENTIFICATION="POSIX" LC_ALL=
docker默認爲POSIX,系統是centos6.7,centos7也有這個問題。centos
在Dockerfile中添加環境變量: ENV LC_ALL en_US.UTF-8tomcat
再啓動docker,查詢locale:centos7
[root@a9f82e7842c1 ~]# locale LANG= LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=en_US.UTF-8
這樣亂碼就沒有了。spa