When working with Debian-based Linux distributions (like Ubuntu), especially in automated environments such as Docker containers, CI/CD pipelines, or cloud init scripts, it's crucial to install packages without manual prompts interrupting the process. By default, APT may ask for user input - such as confirming package installations, dealing with configuration file changes, or language support options - which can cause scripts to hang or fail. To avoid these interruptions, we can run APT in non-interactive mode. This tutorial explains how to install packages non-interactively using APT.
By setting the DEBIAN_FRONTEND
environment variable to noninteractive
, we can instruct the APT to suppress all prompts and proceed with the default options. For example:
sudo DEBIAN_FRONTEND=noninteractive apt install -y python3
The python3
package depends on several other packages - one of them is tzdata
, which configures the system timezone. By default, tzdata
presents a menu for you to select the timezone. Setting the DEBIAN_FRONTEND
to noninteractive
causes tzdata
to bypass interactive prompts and apply default values like UTC.
Leave a Comment
Cancel reply