Setting user prompted values during apt-get install (e.g. tzdata)

Installing php-fpm on Ubuntu 22:04 prompts for some timezone values during install which makes it more difficult to install during a ‘docker build’ since passing -y to apt-get-install is not enough to respond to the prompts.

Here’s what I’m prompted for if I just run ‘apt-get install php-fpm’:

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 3. Antarctica 5. Arctic 7. Atlantic 9. Indian 11. US
2. America 4. Australia 6. Asia 8. Europe 10. Pacific 12. Etc
Geographic area: 8

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

1. Amsterdam 17. Guernsey 33. Monaco 49. Stockholm
2. Andorra 18. Helsinki 34. Moscow 50. Tallinn
3. Astrakhan 19. Isle_of_Man 35. Nicosia 51. Tirane
4. Athens 20. Istanbul 36. Oslo 52. Tiraspol
5. Belfast 21. Jersey 37. Paris 53. Ulyanovsk
6. Belgrade 22. Kaliningrad 38. Podgorica 54. Uzhgorod
7. Berlin 23. Kirov 39. Prague 55. Vaduz
8. Bratislava 24. Kyiv 40. Riga 56. Vatican
9. Brussels 25. Lisbon 41. Rome 57. Vienna
10. Bucharest 26. Ljubljana 42. Samara 58. Vilnius
11. Budapest 27. London 43. San_Marino 59. Volgograd
12. Busingen 28. Luxembourg 44. Sarajevo 60. Warsaw
13. Chisinau 29. Madrid 45. Saratov 61. Zagreb
14. Copenhagen 30. Malta 46. Simferopol 62. Zaporozhye
15. Dublin 31. Mariehamn 47. Skopje 63. Zurich
16. Gibraltar 32. Minsk 48. Sofia
Time zone: 27


Current default time zone: 'Europe/London'
Local time is now: Tue Sep 24 16:39:08 BST 2024.
Universal Time is now: Tue Sep 24 15:39:08 UTC 2024.
Run 'dpkg-reconfigure tzdata' if you wish to change it.

From answers on this post, the easiest option (rather than setting values for the prompted values) is to run in non-interactive mode, and just default the tz to UTC, with:

DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install php-fpm