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开发笔记:Oracle调优
Supported Connection String Attributes To obtain an OracleConnection object in a .NET stored procedure that represents the implicit database connection, set the ConnectionString property of the Oracle
2023-03-05 · Asp-Net-Core开发笔记 · 约 1 分钟
Asp-Net-Core开发笔记:使用ActionFilterAttribute实现非侵入式的参数校验
用ActionFilterAttribute搞非侵入校验,省得重复写代码。支持Query、Body、Route、Header,HttpContext共享数据,但OAuth2.0边学边做,项目乱糟糟,功能凑合。
2024-05-17 · Asp-Net-Core开发笔记 · 约 1 分钟
Asp-Net-Core开发笔记:使用RateLimit中间件实现接口限流
前言 最近一直在忙(2月份沉迷steam,3月开始工作各种忙),好久没更新博客了,不过也积累了一些,忙里偷闲记录一下。 这个需求是这样的,我之前做了个工单系统,现在要对登录、注册、发起工单这些功能做限流,不能让用户请求太频繁。 从 .Net7 开始,已经有内置的限流功能了,但目前我们的项目还在使用 .Net6 LTS 版本,下一个 LTS 没发布之前,暂时不考虑使用 .Net7 这种非 LTS 版
2023-03-20 · Asp-Net-Core开发笔记 · 约 1 分钟
Asp-Net-Core开发笔记:FrameworkDependent搭配docker部署
之前我写过一篇使用 docker 部署 AspNetCore 应用的文章,这种方式搭配 CICD 非常方便, build 之后 push 到私有的 dockerhub ,在生产服务器上 pull 下来镜像就可以直接运行了。 然而,有时需要一种更传统的部署方式,比如在本地打包可执行文件之后直接放到服务器上执行。 这种方式配置完成之后,每次更新只需要重新本地重新 publish 后把可执行文件上传
2023-09-08 · Asp-Net-Core开发笔记 · 约 1 分钟
讨论
共 0 条加载评论中…