如何直接在docker容器内部直接修改时间

$apk update && apk add tzdata
$ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 
$echo "Asia/Shanghai" > /etc/timezone
$date

如图:


5949949-4c6b09d06cd1bdf1.png
时间修改成功

还有一种方法是服务器映射到容器不过我试是不行,也没去研究
$docker cp /etc/localtime [容器ID]:/etc/localtime

猜你喜欢

转载自blog.csdn.net/weixin_34082695/article/details/87396736