1、通过如下命令进入容器内部:
docker exec -ti 容器名称 bash
2、输入:dpkg-reconfigure tzdata
root@eba7e95565e8:/# 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
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 4. Australia 7. Atlantic 10. Pacific 13. Etc
2. America 5. Arctic 8. Europe 11. SystemV
3. Antarctica 6. Asia 9. Indian 12. US
Geographic area: 6
Please select the city or region corresponding to your time zone.
1. Aden 24. Dubai 47. Kuching 70. Shanghai
2. Almaty 25. Dushanbe 48. Kuwait 71. Singapore
3. Amman 26. Famagusta 49. Macau 72. Srednekolymsk
4. Anadyr 27. Gaza 50. Magadan 73. Taipei
5. Aqtau 28. Harbin 51. Makassar 74. Tashkent
6. Aqtobe 29. Hebron 52. Manila 75. Tbilisi
7. Ashgabat 30. Ho_Chi_Minh 53. Muscat 76. Tehran
8. Atyrau 31. Hong_Kong 54. Nicosia 77. Tel_Aviv
9. Baghdad 32. Hovd 55. Novokuznetsk 78. Thimphu
10. Bahrain 33. Irkutsk 56. Novosibirsk 79. Tokyo
11. Baku 34. Istanbul 57. Omsk 80. Tomsk
12. Bangkok 35. Jakarta 58. Oral 81. Ujung_Pandang
13. Barnaul 36. Jayapura 59. Phnom_Penh 82. Ulaanbaatar
14. Beirut 37. Jerusalem 60. Pontianak 83. Urumqi
15. Bishkek 38. Kabul 61. Pyongyang 84. Ust-Nera
16. Brunei 39. Kamchatka 62. Qatar 85. Vientiane
17. Chita 40. Karachi 63. Qostanay 86. Vladivostok
18. Choibalsan 41. Kashgar 64. Qyzylorda 87. Yakutsk
[More] 70
19. Chongqing 42. Kathmandu 65. Rangoon 88. Yangon
20. Colombo 43. Khandyga 66. Riyadh 89. Yekaterinburg
21. Damascus 44. Kolkata 67. Sakhalin 90. Yerevan
22. Dhaka 45. Krasnoyarsk 68. Samarkand
23. Dili 46. Kuala_Lumpur 69. Seoul
Time zone: 19
Current default time zone: 'Asia/Chongqing'
Local time is now: Tue Feb 26 11:32:29 CST 2019.
Universal Time is now: Tue Feb 26 03:32:29 UTC 2019.
按照步骤选择需要的时区,这里面的time zone时区只有重庆的,所以这里选择重庆
3、验证:
root@eba7e95565e8:/# dpkg-reconfigure -f noninteractive tzdata
Current default time zone: 'Asia/Chongqing'
Local time is now: Tue Feb 26 11:36:05 CST 2019.
Universal Time is now: Tue Feb 26 03:36:05 UTC 2019.
检查发现时区已经修改,重启容器即可。