1.在Dockerfile中設(shè)置鏡像時(shí)區(qū)
# 設(shè)定時(shí)區(qū)
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
2.創(chuàng)建容器時(shí)設(shè)置時(shí)區(qū)
將宿主機(jī)與容器的時(shí)間進(jìn)行掛載,直接使用宿主機(jī)的時(shí)區(qū)文章來源地址http://www.zghlxwxcb.cn/news/detail-584483.html
-v /etc/localtime:/etc/localtime
3.進(jìn)入容器進(jìn)行設(shè)置
1)進(jìn)入容器內(nèi):docker exec -it 容器名 /bin/bash
2)設(shè)定時(shí)區(qū)
rm /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
文章來源:http://www.zghlxwxcb.cn/news/detail-584483.html
到了這里,關(guān)于Docker系列---【Docker設(shè)置時(shí)區(qū)的三種方式】的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!