Debconf: unable to initialize frontend: Dialog debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)

Does anyone know how to suppress this warning? The warning occurs while building a workspace image and an apt package is installed with -y and a prompt is actually auto set to y during the install. this was happening specifically with php7.4fpm but I think it could happen with any package installed with the-y option that prompts a user.

I tried this without success:

RUN DEBIAN_FRONTEND=noninteractive sudo apt-get update -q \
    && sudo apt-get -y install php7.4-fpm rsync grc \
    && sudo apt-get clean

I fixed it with this:

RUN echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections \
    && sudo apt-get update -q \
    && sudo apt-get -y install php7.4-fpm rsync grc \
    && sudo apt-get clean