曦远 (DealiAxy)一份私人的文字刊物

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 许可协议。转载请注明出处!

相关文章

Asp-Net-Core开发笔记:使用RateLimit中间件实现接口限流

前言 最近一直在忙(2月份沉迷steam,3月开始工作各种忙),好久没更新博客了,不过也积累了一些,忙里偷闲记录一下。 这个需求是这样的,我之前做了个工单系统,现在要对登录、注册、发起工单这些功能做限流,不能让用户请求太频繁。 从 .Net7 开始,已经有内置的限流功能了,但目前我们的项目还在使用 .Net6 LTS 版本,下一个 LTS 没发布之前,暂时不考虑使用 .Net7 这种非 LTS 版

2023-03-20 · Asp-Net-Core开发笔记 · 约 1 分钟

Asp-Net-Core开发笔记:接口返回json对象出现套娃递归问题

前言 看了下推送记录,一个月前,OK,我又变成月更了o(╯□╰)o,这绝对不行![○・`Д´・ ○] 所以今天来更新了 其实不是我懒得更新或者是太忙,其实是最近在写一篇很长的博客,一直没写完( Ĭ ^ Ĭ ) 好吧,先进入正题…… 有一个关于WebApi序列化的问题,跟设计有关,但在涉及到关联字段的时候经常会遇到。 实体类 先看看实体类定义,限于篇幅,只保留几个关键字段。 public class

2022-02-16 · Asp-Net-Core开发笔记 · 约 1 分钟

讨论

共 0 条

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

加载评论中…