Docker 修改时区

碰到Oracle 在windows服务器上,asp.net core web api 在linux的docker中

碰到问题

说ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region not found

这应该是服务器时区和oracle不一致导致的, docker默认时区都是  Etc/UTC,而我的Oracle 数据库中没有这个时区

解决:

通过语句可以查看到Oracle有哪些时区

select tzname, tzabbrev from v$timezone_names

我这里 亚洲的只有重庆,所以,我下面的操作都是选的重庆

 

 

在网上找了好多资料,有的说,改oracle什么配置文件,加什么参数,都没有用。

有的说改docker 时区,确实是的,但是好多方法都不能用,也没有说明白。

我的操作系统是 Ubuntu 16.04 修改时区! 尝试各种各种改时区的方法,都没有用。

我的解决办法

1、进入docker  

docker exec d7f -it /bin/bash  //d7f 是容器的id或名称,我这里是id

2、执行命令:dpkg-reconfigure tzdata

root@d7f2ead6bdfa:/app# dpkg-reconfigure tzdata
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Configuring tzdata
------------------

Please select the geographic area in which you live. Subsequent configuration questions will narrow this down by presenting a list of cities, representing the time zones in which they are located.

  1. Africa  2. America  3. Antarctica  4. Australia  5. Arctic  6. Asia  7. Atlantic  8. Europe  9. Indian  10. Pacific  11. SystemV  12. US  13. Etc
Geographic area: 6

Please select the city or region corresponding to your time zone.

  1. Aden    7. Ashgabat  13. Barnaul     19. Chongqing  25. Dushanbe     31. Hong_Kong  37. Jerusalem  43. Khandyga      49. Macau     55. Novokuznetsk  61. Pyongyang  67. Samarkand      73. Tashkent  79. Tomsk          85. Vladivostok
  2. Almaty  8. Atyrau    14. Beirut      20. Colombo    26. Famagusta    32. Hovd       38. Kabul      44. Kolkata       50. Magadan   56. Novosibirsk   62. Qatar      68. Seoul          74. Tbilisi   80. Ujung_Pandang  86. Yakutsk
  3. Amman   9. Baghdad   15. Bishkek     21. Damascus   27. Gaza         33. Irkutsk    39. Kamchatka  45. Krasnoyarsk   51. Makassar  57. Omsk          63. Qyzylorda  69. Shanghai       75. Tehran    81. Ulaanbaatar    87. Yangon
  4. Anadyr  10. Bahrain  16. Brunei      22. Dhaka      28. Harbin       34. Istanbul   40. Karachi    46. Kuala_Lumpur  52. Manila    58. Oral          64. Rangoon    70. Singapore      76. Tel_Aviv  82. Urumqi         88. Yekaterinburg
  5. Aqtau   11. Baku     17. Chita       23. Dili       29. Hebron       35. Jakarta    41. Kashgar    47. Kuching       53. Muscat    59. Phnom_Penh    65. Riyadh     71. Srednekolymsk  77. Thimphu   83. Ust-Nera       89. Yerevan
  6. Aqtobe  12. Bangkok  18. Choibalsan  24. Dubai      30. Ho_Chi_Minh  36. Jayapura   42. Kathmandu  48. Kuwait        54. Nicosia   60. Pontianak     66. Sakhalin   72. Taipei         78. Tokyo     84. Vientiane
Time zone: 19


Current default time zone: 'Asia/Chongqing'
Local time is now:      Mon Nov 12 12:56:26 CST 2018.
Universal Time is now:  Mon Nov 12 04:56:26 UTC 2018.

 

一步一步选下来,选你自己要的时区

3、验证

root@d7f2ead6bdfa:/app# dpkg-reconfigure -f noninteractive tzdata

Current default time zone: 'Asia/Chongqing'
Local time is now:      Mon Nov 12 12:56:32 CST 2018.
Universal Time is now:  Mon Nov 12 04:56:32 UTC 2018.

看我的时区已经改了,我这里重启了一下容器,程序跑起来了。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值