例如在Dockerfile中,有RUN apt-get install -y dracut,因为涉及交互式选择项(如下),docker build的时候会报错。

root@c3210a8a85bf:/# apt-get install -y dracut
Reading package lists... Done
Building dependency tree
.....
.....
The layout of keyboards varies per country, with some countries having multiple common layouts. Please select the country of origin for the keyboard of this computer.

  1. Afghani           20. Danish                                     39. Georgian                   58. Lithuanian           77. Spanish
  2. Albanian          21. Dhivehi                                    40. German                     59. Macedonian           78. Spanish (Latin American)
  3. Amharic           22. Dutch                                      41. German (Austria)           60. Maltese              79. Swahili (Kenya)
  4. Arabic            23. Dzongkha                                   42. Greek                      61. Maori                80. Swahili (Tanzania)
  5. Arabic (Morocco)  24. English (Cameroon)                         43. Hebrew                     62. Moldavian            81. Swedish
  6. Arabic (Syria)    25. English (Ghana)                            44. Hungarian                  63. Mongolian            82. Switzerland
  7. Armenian          26. English (Nigeria)                          45. Icelandic                  64. Montenegrin          83. Taiwanese
  8. Azerbaijani       27. English (South Africa)                     46. Indian                     65. Nepali               84. Tajik
  9. Bambara           28. English (UK)                               47. Iraqi                      66. Norwegian            85. Thai
  10. Bangla           29. English (US)                               48. Irish                      67. Persian              86. Tswana
  11. Belarusian       30. Esperanto                                  49. Italian                    68. Polish               87. Turkish
  12. Belgian          31. Estonian                                   50. Japanese                   69. Portuguese           88. Turkmen
  13. Bosnian          32. Faroese                                    51. Japanese (PC-98xx Series)  70. Portuguese (Brazil)  89. Ukrainian
  14. Braille          33. Filipino                                   52. Kazakh                     71. Romanian             90. Urdu (Pakistan)
  15. Bulgarian        34. Finnish                                    53. Khmer (Cambodia)           72. Russian              91. Uzbek
  16. Burmese          35. French                                     54. Korean                     73. Serbian              92. Vietnamese
  17. Chinese          36. French (Canada)                            55. Kyrgyz                     74. Sinhala (phonetic)   93. Wolof
  18. Croatian         37. French (Democratic Republic of the Congo)  56. Lao                        75. Slovak
  19. Czech            38. French (Guinea)                            57. Latvian                    76. Slovenian
Country of origin for the keyboard:

 通过搜索找到了解决方式,命令改成RUN DEBIAN_FRONTEND=noninteractive apt-get install -y dracut 就没有交互式的选项了。

DEBIAN_FRONTEND=noninteractive同样适用于shell 脚本

参考链接:https://stackoverflow.com/questions/38165407/installing-lightdm-in-dockerfile-raises-interactive-keyboard-layout-menu

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐