Docker容器时区设置与中文字符支持

时区设置(通过Dockerfile)

ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

或者也可以直接这样:

# Set the timezone.
RUN sudo echo "America/New_York" > /etc/timezone
RUN sudo dpkg-reconfigure -f noninteractive tzdata

更多参考:
http://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes
https://github.com/docker/docker/issues/12084
http://tedwise.com/2015/05/02/setting-the-timezone-in-a-docker-image

中文支持

新建Dockerfile

FROM ubuntu:trusty

# Ensure UTF-8 locale
#COPY locale /etc/default/locale
RUN locale-gen zh_CN.UTF-8 &&\
  DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales
RUN locale-gen zh_CN.UTF-8  
ENV LANG zh_CN.UTF-8  
ENV LANGUAGE zh_CN:zh  
ENV LC_ALL zh_CN.UTF-8  

然后执行构建

docker build -t xbyubuntu .

更多参考:
http://stackoverflow.com/questions/28405902/how-to-set-the-locale-inside-a-docker-container
https://github.com/abevoelker/docker-ubuntu-locale/blob/master/Dockerfile
http://blog.shiqichan.com/Input-Chinese-character-in-docker-bash/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值