Apt install asks for user input when building a Docker image

$ cat Dockerfile 
FROM ubuntu:focal
RUN apt -y update && \
apt -y upgrade && \
apt -y install php

$ docker build .
Bla bla...
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: 2
^C

As you can see, at a certain point it asks to choose the geographical area, and for example I press 2 (America).
But nothing happens anymore. The process stops, and to stop it I have to press CTRL+C

Why?

Add this right after FROM ubuntu:focal

ARG DEBIAN_FRONTEND=noninteractive

It will only be available during build time and apt will read the varibale, see it is a noninteractive environment and wont ask you to choose anything.

4 Likes