在Docker中配置nano和timezone

修改源

修改images中镜像源sources.list

echo "deb http://mirrors.aliyun.com/debian sid main" >/etc/apt/sources.list
apt-get update

install nano

nano是一款神奇的编辑器,个人比较喜欢多余vim

apt-get update && apt-get install -y nano && export TERM=xterm

timezone

如果不对docker进行处理,默认的时区就是Etc/UTC,就是UTC标准时间,so,需要修改一下,改为中国标准时间

对于运行中的container,需要进入交互模式下进行操作:

[email protected]:~# docker exec -it cache_blog_1 /bin/bash
[email protected]:/# cat /etc/timezone
Etc/UTC
[email protected]:/# echo "Asia/Shanghai" > /etc/timezone
[email protected]:/# dpkg-reconfigure -f noninteractive tzdata
Current default time zone: 'Asia/Shanghai'
Local time is now:      Sun Oct  9 15:09:29 CST 2016.
Universal Time is now:  Sun Oct  9 07:09:29 UTC 2016.

到此container的timezone已经由UTC改为CST

避免每起一个container就去改timezone很不便利,可以将其写入到Dockerfile中

RUN echo "Asia/Shanghai" > /etc/timezone
RUN dpkg-reconfigure -f noninteractive tzdata

补:debian设置时区方法dpkg-reconfigure tzdata

*****
Written by ysicing on 09 October 2016