Using the interactive apt front-end in Dockerfile RUN instructions is discouraged because its user-facing behavior can change between versions and it may prompt for input during non-interactive image builds. This can cause build failures or incomplete/incorrect package installations that leave images outdated or inconsistent.
This rule flags Dockerfile RUN commands that invoke apt as a command (for example RUN apt ...) and instead requires using scripting-friendly tools such as apt-get and apt-cache. Replace apt with apt-get/apt-cache, run apt-get update before installs, use non-interactive and affirmative flags (for example, -y --no-install-recommends), and clean apt caches to reduce image size and avoid stale state.
FROMdebian:bookworm# The literal string "apt " appears here inside an echo argument used to# write a sources.list entry — this is NOT a `RUN apt ...` invocation and# must not be flagged.RUNecho"deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main"\
> /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends postgresql-client-16 \
&& rm -rf /var/lib/apt/lists/*HEALTHCHECK CMD curl --fail http://localhost:3000 ||exit1