This warning appears when running apt-get in non-interactive environments like Docker containers or CI/CD pipelines. While it doesn't prevent package installation, it indicates that debconf cannot access a terminal for interactive configuration. Setting DEBIAN_FRONTEND=noninteractive or redirecting stdin resolves the issue.
The "dpkg-preconfigure: unable to re-open stdin: No such file or directory" error occurs when the Debian package configuration tool (debconf) tries to interact with the terminal but finds no valid input stream. During package installation, dpkg-preconfigure attempts to ask configuration questions using debconf's interactive frontends (Dialog, Readline, Teletype) in sequence. When running in a container, automated environment, or with redirected stdin, none of these frontends can function properly. Debconf falls through all available frontends and ultimately fails when trying to re-open stdin. In most cases, packages still install successfully despite this warning, but it clutters logs and indicates improper environment configuration. The error is most common in Docker builds, Vagrant provisioning, CI/CD pipelines (GitHub Actions, GitLab CI), and automated server provisioning tools.
The most reliable solution is to set the environment variable before running apt commands. This tells debconf to use the noninteractive frontend, which skips all prompts and uses default answers:
FROM ubuntu:22.04
# Set noninteractive frontend
ENV DEBIAN_FRONTEND=noninteractive
# Now apt-get runs without trying to prompt
RUN apt-get update && apt-get install -y \
curl \
git \
wget
# Optional: reset for subsequent stages
ENV DEBIAN_FRONTEND=dialogThe ENV instruction works for all RUN commands that follow it in the same image stage. If using multi-stage builds, set it in each stage that needs it.
Important: Use ENV (persistent) rather than ARG (build-time only). Some older Docker versions don't properly pass ARG to RUN commands.
Some debconf-related tools try to show changelogs. Disable them as well:
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV APT_LISTCHANGES_FRONTEND=none
RUN apt-get update && apt-get install -y curl gitThis prevents apt-listchanges from trying to interact during installation.
Optionally configure locale settings to avoid perl warnings and ensure consistent encoding:
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV LANGUAGE=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8
RUN apt-get update && apt-get install -y curl gitThis is optional but recommended for cleaner build logs.
For existing containers or systems that already have the error, you can disable preconfiguration by modifying the debconf configuration:
# Comment out the DPkg preconfigure line
sudo ex +"%s@DPkg@//DPkg" -cwq /etc/apt/apt.conf.d/70debconf
# Or simply remove the file if you don't need debconf at all
sudo rm /etc/apt/apt.conf.d/70debconfThen reconfigure debconf to use noninteractive mode:
sudo dpkg-reconfigure debconf -f noninteractive -p criticalThis is a container-level fix for running systems, but in Docker it's better to set ENV variables.
If you're running apt in interactive mode (not Docker), be careful with stdin redirection:
# BAD - redirects stdin, causes preconfigure to fail
apt-get install -y package < /dev/null
# GOOD - no stdin redirection, relies on -y flag
apt-get install -y package
# BETTER - set environment variable
DEBIAN_FRONTEND=noninteractive apt-get install -y packageThe -y flag automatically answers 'yes' to prompts, but debconf still attempts initialization before seeing the flag.
If the error doesn't block your build and you just want to silence it, redirect stderr:
apt-get update 2>/dev/null
apt-get install -y package 2>/dev/nullOr in Dockerfile:
RUN apt-get update 2>/dev/null && \
apt-get install -y curl 2>/dev/nullNote: This just hides the warning; it's not a proper fix. The recommended approach is to set DEBIAN_FRONTEND.
Why does this happen in Docker? Docker containers have no controlling terminal (TTY) by default. When dpkg-preconfigure runs, it tries to open /dev/tty to access stdin, but this device doesn't exist. It then falls back through Dialog (requires tty), Readline (requires tty), and Teletype frontends before giving up.
Difference between preconfigure and reconfigure: dpkg-preconfigure runs BEFORE package installation (asking configuration questions upfront), while dpkg-reconfigure runs AFTER (modifying existing package configuration). Both require a terminal unless DEBIAN_FRONTEND is set to noninteractive.
Multi-stage builds: If using multi-stage builds, set DEBIAN_FRONTEND in each stage that runs apt commands:
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y build-essential
FROM ubuntu:22.04 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y libcurl4
COPY --from=builder /app /appUsing ARG vs ENV: Some guides suggest using ARG before FROM and passing it with --build-arg. This approach is less reliable. Prefer ENV for clarity and consistency.
Performance impact: Using DEBIAN_FRONTEND=noninteractive may slightly speed up builds since debconf doesn't try to initialize interactive frontends. In Docker, this is usually negligible.
Why it's "just a warning": Packages still install because debconf gives up and apt-get continues. The package's install scripts run successfully; only the configuration interaction is skipped. In most cases, this is exactly what you want in automation.
E: Cannot set to hold: package 'package-name' is not installed
How to fix "Cannot set to hold" error when package is not installed in APT
debconf: unable to initialize frontend: Dialog
How to fix "debconf: unable to initialize frontend: Dialog" in APT
E: Could not connect to proxy server
Could not connect to proxy server
dpkg: serious warning: files list file for package 'package-name' contains empty filename
How to fix "files list file contains empty filename" in APT
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt