DOCKER中centos7的中文支持

直接編寫看下可否改變成識別中文字體php

寫到你的~/.bashrc裏吧,而後重啓終端(我寫的是英文的啊,改爲你要的)html

export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8

 不行的話就老老實實使用下面的方法mysql

方法一:進入docker裏配置nginx

添加中文環境編碼,安裝兩個包
# yum install kde-l10n-Chinese -y
# yum install glibc-common -y
轉化語言環境和字符集
# localedef -c -f UTF-8 -i zh_CN zh_CN.utf8
添加定義到系統環境變量
# vi /etc/profile
export LC_ALL=zh_CN.utf8
執行生效
# source /etc/profile

方法二:編寫dockerfile文件web

FROM centos
MAINTAINER djl
#設置系統編碼
RUN yum install kde-l10n-Chinese -y
RUN yum install glibc-common -y
RUN localedef -c -f UTF-8 -i zh_CN zh_CN.utf8
#RUN export LANG=zh_CN.UTF-8
#RUN echo "export LANG=zh_CN.UTF-8" >> /etc/locale.conf
#ENV LANG zh_CN.UTF-8
ENV LC_ALL zh_CN.UTF-8

本身在實踐中編寫的dockerfile實例redis

FROM centos:7
MAINTAINER nsh

RUN  yum -y  localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm  && \
yum -y install nginx && \
yum -y install kde-l10n-Chinese && \
yum -y install glibc-common -y  && \
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm && \
yum -y install php72w php72w-fpm php72w-mbstring php72w-common php72w-gd  php72w-mysqlnd php72w-xml php72w-cli php72w-devel php72w-pecl-memcached php72w-pecl-redis php72w-opcache php72w-pecl-redis php72w-bcmath php72w-gd php72w-mysqli

ADD nginx.conf /etc/nginx/nginx.conf
RUN mkdir /code
RUN localedef -c -f UTF-8 -i zh_CN zh_CN.utf8
WORKDIR /code
ADD cs.tar.gz .     ###這裏是本身項目的包
ENV LC_ALL zh_CN.UTF-8
RUN chown -R  apache.apache .
RUN chown -R  apache.apache /var/log/nginx

EXPOSE 80
ADD init.sh /init.sh

CMD ["/bin/bash","/init.sh"] 

 以後我進入容器中測試(建立中文文件夾和在文件中編輯中文)sql

              

 

 親測有效..........................docker

參考博客:apache

Dockerfile 建立容器內中文亂碼問題解決centos

https://blog.csdn.net/weixin_39153210/article/details/83617792

解決docker容器中Centos7系統的中文亂碼

https://blog.csdn.net/xw_2_xh/article/details/86497636

centos7在docker環境中亂碼問題

https://www.cnblogs.com/djlsunshine/p/11282867.html

相關文章
相關標籤/搜索