Trying to create a custom Docker image but getting asked for question during a RUN step

Viewed 1055

I'm trying to create a custom Docker image and during one of the RUN steps I'm getting asked to select some 'menu' choice .. which hangs/stops the image from continuing/getting made.

Here's the Dockerfile:

FROM ubuntu:latest

RUN apt update

# install OpenCV
RUN apt install python3-opencv -y

# Test that OpenCV has been installed
RUN python3 -c "import cv2; print(cv2.__version__)"

and here's the last few lines in the build output:

....
Setting up libsnappy1v5:amd64 (1.1.8-1build1) ...
Setting up poppler-data (0.4.9-2) ...
Setting up libkrb5support0:amd64 (1.17-6ubuntu4) ...
Setting up libsasl2-modules-db:amd64 (2.1.27+dfsg-2) ...
Setting up tzdata (2020a-0ubuntu0.20.04) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Configuring tzdata
------------------

Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.

  1. Africa      4. Australia  7. Atlantic  10. Pacific  13. Etc
  2. America     5. Arctic     8. Europe    11. SystemV
  3. Antarctica  6. Asia       9. Indian    12. US
Geographic area: 

This is part of the 3rd step => RUN p3 p3-opencv

How can I get this step to sorta auto completed? I'm guessing that when trying to install python-opencv I am missing dependencies and/or needing some dependencies to be updated. This is fine, and it's trying to update/install these, but needs some user-interaction.

1 Answers

You can use DEBIAN_FRONTEND=noninteractive

FROM ubuntu:latest
RUN apt update
ENV DEBIAN_FRONTEND=noninteractive

# install OpenCV
RUN apt install python3-opencv -y

# Test that OpenCV has been installed
RUN python3 -c "import cv2; print(cv2.__version__)"
Related