docker内時間和系統時間差8小時
d6612fcb89aa為我的docker容器id
[[email protected] ~]# docker exec d6612fcb89aa date ---檢視docker容器時間
Mon Aug 30 06:55:10 UTC 2021
[[email protected] ~]# docker exec -it d6612fcb89aa sh -c 'ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime' ---建立軟連結
ln: failed to create symbolic link '/etc/localtime': File exists
[[email protected] ~]# docker exec -ti -u root gerrit sh ----以root進入gerrit容器
sh-4.4# rm localtime ----删除檔案
sh-4.4#exit
[[email protected] ~]# docker exec -it d6612fcb89aa sh -c 'ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime'
ln: failed to create symbolic link '/etc/localtime': Permission denied ---權限不夠被禁止
[[email protected] ~]# docker exec -it -u root d6612fcb89aa sh -c 'ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime' ----以root身份操作
[[email protected] ~]# docker exec -it d6612fcb89aa sh -c 'date'
Mon Aug 30 15:06:42 CST 2021 ----更改成功
參考資料:https://zhuanlan.zhihu.com/p/104198177
https://blog.csdn.net/HYZX_9987/article/details/119149982