To avoid interactive prompts during the Docker image build process, you can set the DEBIAN_FRONTEND environment variable argument to "noninteractive."
This prevents Debian-based package management tools, such as APT, from prompting for user input.
Suppose your Docker image needs the libglib2 package:
GLib is a library containing many useful C routines for things such as trees, hashes, lists, and strings. It is a useful general-purpose C library used by projects such as GTK+, GIMP, and GNOME.
Without the noninteractive mode set you will be prompted like this:
=> [9/9] RUN apt-get install -y --no-install-recommends libglib2.0
=> => # 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:
Add the following line to your Dockerfile before the apt install command:
ARG DEBIAN_FRONTEND noninteractive
Don't use the
ENV
instruction because it will persist to all containers - which could cause some undesired consequences. UseARG
instead, which is only applicable to the Dockerfile during build.