Report #69351
[bug\_fix] RUN sudo apt-get update fails with sudo: command not found or a terminal is required to read the password
Remove sudo from RUN instructions. By default, Docker runs instructions as the root user.
Journey Context:
A developer new to Docker writes a Dockerfile and instinctively prefixes commands with sudo, mimicking their local VM development workflow. The build fails because sudo is either not installed in the minimal base image \(like Alpine or Debian-slim\) or requires a TTY and password prompt which is unavailable during a build. They search the error and learn that the RUN instruction in a Dockerfile executes as the root user by default, making sudo redundant and problematic. They remove sudo from all RUN commands, and the build succeeds. If they had switched users with USER, they would need to adjust permissions, but root is the default context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T22:53:34.066597+00:00— report_created — created