This error occurs when dpkg attempts to ask about configuration file changes during package installation or upgrade in a non-interactive environment. Since stdin is empty or closed, the prompt cannot be answered and the operation fails.
The "end of file on stdin at conffile prompt" error occurs when dpkg tries to prompt the user about how to handle configuration file changes, but cannot read user input because stdin is empty or closed. During package upgrades, dpkg may find that a configuration file (conffile) has been modified by the system administrator but also has a newer version in the package. dpkg asks the user whether to keep the existing version or use the new one. In non-interactive environments (Docker containers, CI/CD pipelines, automated scripts), this prompt blocks the operation and causes an EOF error. This is particularly common in Docker builds and automated update systems where the standard input stream is not connected to a terminal.
Set the DEBIAN_FRONTEND environment variable to suppress interactive prompts. This tells the Debian package system to make automatic decisions instead of prompting:
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get upgrade -yIn Docker, add this to your Dockerfile:
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get upgrade -yOr use it inline for a single command:
DEBIAN_FRONTEND=noninteractive apt-get install -y package-nameUse dpkg options to automatically decide how to handle conflicting configuration files:
# Use --force-confold to keep the existing configuration file
apt-get upgrade -y -o Dpkg::Options::="--force-confold"
# Use --force-confnew to use the new configuration file from the package
apt-get upgrade -y -o Dpkg::Options::="--force-confnew"
# Use --force-confdef to use the default action (usually keep old)
apt-get upgrade -y -o Dpkg::Options::="--force-confdef"Combine multiple options for robustness:
apt-get upgrade -y \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold"For the most reliable non-interactive upgrades, use both methods together:
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get upgrade -y \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold"This approach handles both the interactive prompts from apt and the conffile prompts from dpkg.
If dpkg was interrupted mid-installation, you may see a message to run dpkg --configure -a. Use it with the same non-interactive approach:
# Fix interrupted packages
export DEBIAN_FRONTEND=noninteractive
dpkg --configure -a \
--apt \
--force-confdef \
--force-confoldOr with apt:
DEBIAN_FRONTEND=noninteractive apt-get install -f \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold"If the above methods don't work, redirect stdin from /dev/null or provide empty input:
# Redirect from /dev/null
apt-get upgrade -y < /dev/null
# Or feed empty lines
yes '' | apt-get upgrade -y
# For dpkg directly
dpkg --configure -a < /dev/nullThis ensures stdin is closed cleanly rather than left open waiting for input.
--force-confold vs --force-confnew: The choice depends on your use case. --force-confold keeps existing customizations (safer for production), while --force-confnew uses package defaults (better for fresh installations). Most automated systems use --force-confold to preserve existing configurations.
Debconf Pre-seeding: For more complex packages with multiple configuration questions, you can pre-seed debconf responses. This stores answers in the debconf database before installation, preventing prompts entirely:
echo "package-name key value" | debconf-set-selectionsDocker Best Practices: In Dockerfiles, set DEBIAN_FRONTEND=noninteractive early and combine it with apt options. Also use --no-install-recommends to reduce package count and potential conflicts:
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get upgrade -y \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" && \
apt-get install --no-install-recommends -y package-nameImportant Note: If a package requires interactive configuration in non-interactive mode to function correctly, this may indicate a release-critical bug in Debian. Such issues should be reported to the Debian bug tracking system.
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: Sub-process /usr/bin/dpkg returned an error code (2)
How to fix "Sub-process /usr/bin/dpkg returned an error code (2)" in APT
dpkg-divert: error: rename involves overwriting 'path' with different file
How to fix dpkg-divert rename conflicts in APT
E: Sub-process /usr/bin/dpkg returned an error code (1) during kernel installation
How to fix "dpkg returned an error code (1)" in APT kernel installation
dpkg: dependency problems prevent configuration of triggers
dpkg: dependency problems prevent configuration of triggers in apt