Skip to content

Instantly share code, notes, and snippets.

@jaamarks
Last active March 13, 2024 00:29
Show Gist options
  • Save jaamarks/e2c5c3c465b532e1610edc37d5649e93 to your computer and use it in GitHub Desktop.
Save jaamarks/e2c5c3c465b532e1610edc37d5649e93 to your computer and use it in GitHub Desktop.
Dockerfile: ARG DEBIAN_FRONTEND noninteractive

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.

Example: Interactive Prompt during APT Package Installation

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:

Solution

Add the following line to your Dockerfile before the apt install command: ARG DEBIAN_FRONTEND noninteractive

@jaamarks
Copy link
Author

jaamarks commented Mar 12, 2024

Don't use the ENV instruction because it will persist to all containers - which could cause some undesired consequences. Use ARG instead, which is only applicable to the Dockerfile during build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment