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.
看我的時區已經改了,我這里重啟了一下容器,程序跑起來了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM