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 -
目录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
- https://blog.csdn.net/LIKEGAKKI/article/details/120758276
- Fixing the netcore Oracle connection error in a Docker container (timezone region not found): https://www.cnblogs.com/xtjatswc/p/11350262.html
_EOF_
Asp-Net-Core Development Notes: A Small Pitfall When Deploying with Docker
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
Asp-Net-Core开发笔记:EFCore统一实体和属性命名风格
EFCore居然没有内置命名转换?得自己写正则或用插件,真是折腾。插件一行代码搞定,但为什么EFCore不直接支持?命名风格转换,要么自己写代码,要么依赖第三方,真费劲。
2023-10-10 · Asp-Net-Core开发笔记 · 约 1 分钟
Asp-Net-Core开发笔记:使用alpine镜像并加入健康检查
用alpine镜像?不过是把体积砍半,健康检查加个路径就完事。wget自带,何必装curl,真是多余。发布选linux-musl-x64,不然别想跑。
2024-04-19 · Asp-Net-Core开发笔记 · 约 1 分钟
Asp-Net-Core开发笔记:给SwaggerUI加上登录保护功能
既要在项目发布后访问 SwaggerUI ,又要保证一定的安全性,本文提供的思路或许是一种比较简单又有效的解决方案。
2024-05-21 · Asp-Net-Core开发笔记 · 约 1 分钟
Asp-Net-Core开发笔记:API版本管理
对于Web API应用程序而言,随着时间的推移以及需求的增加或改变,API必然会遇到升级的需求。事实上,Web API应用程序应该从创建时就考虑到API版本的问题。业务的调整、功能的增加、接口的移除与改名、接口参数变动、实体属性的添加、删除和更改等都会改变API的功能,从而带来版本的变更。
2023-06-09 · Asp-Net-Core开发笔记 · 约 1 分钟
讨论
共 0 条加载评论中…