修改docker容器内时区

作者:admin 发布:2018-08-24 浏览:3035次

使用ntp同步网络时间

ntpdate time.nist.gov

报错:

 Can't adjust the time of day: Operation not permitted

正确的修改容器内时区:


docker cp /etc/localtime [容器ID或者NAME]:/etc/



如果镜像是alpine  linux 使用以下命令:

apk add -U tzdata

ls /usr/share/zoneinfo

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime


如果镜像是debian 使用以下命令:(这种方式重启容器就失效了)

# echo "export TZ='Asia/Shanghai'"  >> /etc/profile  
# cat /etc/profile |grep TZ  
# source /etc/profile
# date -R
# date


Comments (0)