cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #同时适用于Centos7
时间: 2023-08-10 16:05:13 浏览: 573
在Dockerfile中,可以使用以下命令来设置时区:
```
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
```
这个命令会将本机的时区设置为Asia/Shanghai,并将本机时间同步到容器中。\[1\]
对于CentOS系统,你也可以使用以下命令来设置时区:
```
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
```
这个命令会将本机的时区设置为Asia/Shanghai。\[3\]
#### 引用[.reference_title]
- *1* *2* [不同Docker操作系统的时区同步](https://blog.csdn.net/smooth00/article/details/107058753)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [Dockerfile 时区设置及 Java 时区设置(/etc/localtime和/etc/timezone)](https://blog.csdn.net/alinyua/article/details/80944543)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文