返回文章列表文章索引阅读全文
STARBLOG / 阅读手记
Asp-Net-Core开发笔记

Asp-Net-Core Development Notes: A Small Pitfall When Deploying with Docker

Uh-oh I just mentioned trying to deploy an AspNetCore app with Docker, and then I ran into a problem as soon as I started work today = =… This project uses Oracle as the database. Running it directly was fine before, but running it in Docker threw this error: ORA-01882: timezone region not found Looking at the error message, it seems the timezone is wrong. Let's check the time on the server and in Docker respectively: [root@localhost ~]# date -

曦远 (DealiAxy)约 3 分钟
目录2 个章节

Uh-oh

I just mentioned trying to deploy an AspNetCore app with Docker, and then I ran into a problem as soon as I started work today = =…

This project uses Oracle as the database. Running it directly was fine before, but running it in Docker threw this error:

ORA-01882: timezone region not found

Looking at the error message, it seems the timezone is wrong. Let's check the time on the server and in Docker respectively:

[root@localhost ~]# date -R
Mon, 29 Nov 2021 17:07:30 +0800
root@9abab841b6b4:/app# date -R
Mon, 29 Nov 2021 09:08:22 +0000

Yep, the timezone setting is indeed wrong…

After some effort with search engines, I found a simple solution:

Just add these two lines at the end of the project's Dockerfile~

#设置时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

Run docker-compose up again, and the problem was indeed solved~

References

_EOF_

Asp-Net-Core Development Notes: A Small Pitfall When Deploying with Docker

本文作者:
程序设计实验室
版权声明:
本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!

相关文章

讨论

共 0 条

良言一句三冬暖,恶语伤人六月寒。

加载评论中…