Dockerfile prevents popup of apt install interactive view

Original link: https://blog.frytea.com/archives/749/

75

When performing an apt install in a Dockerfile, some packages may pop up interactive views during the installation process, such as asking the user to accept the package license or configure package parameters, etc. During a Docker build, these views may cause the build to fail or have unexpected results due to the inability to interact interactively. To avoid these problems, you can avoid popping up the interactive view during the Docker build process by:

Use the -y parameter in the apt-get command, which means to automatically answer “yes” to all inquiries, for example:

 RUN apt-get update && apt-get install -y package-name

In this example, the -y parameter tells apt-get to automatically answer “yes” to all queries without manual confirmation.

Set the environment variable DEBIAN_FRONTEND to noninteractive in the Dockerfile, for example:

 ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && apt-get install -y package-name

In this example, DEBIAN_FRONTEND is set to noninteractive, indicating that no interactive interface is required.

With these methods, you can avoid the apt install pop-up interactive view during the Docker build process, thereby ensuring a smooth build process. It should be noted that automatically answering all inquiries may bring certain security risks, and an appropriate solution should be selected according to actual needs.

This article is transferred from: https://blog.frytea.com/archives/749/
This site is only for collection, and the copyright belongs to the original author.