python - 尝试创建自定义 Docker 映像,但在 RUN 步骤中被询问问题
问题描述
我正在尝试创建一个自定义 Docker 映像,并且在其中一个RUN
步骤中,我被要求选择一些“菜单”选项..它会挂起/停止图像继续/制作。
这是 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__)"
这是构建输出中的最后几行:
....
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:
这是第三步的一部分 =>RUN p3 p3-opencv
我怎样才能让这一步自动完成?我猜想在尝试安装python-opencv
时我缺少依赖项和/或需要更新一些依赖项。这很好,它正在尝试更新/安装这些,但需要一些用户交互。
解决方案
您可以使用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__)"
推荐阅读
- python - Boolean ,正确答案是什么,为什么?
- keras - keras 无法在内置函数中打印
- c++ - 有没有一种方法或方法可以检查用户是否访问了 QTabWidget 上的某个标签页?
- c# - Asp .Net Mvc:如何通过 Ajax 调用加载 RDLC 报告
- javascript - 当文本框中输入的金额超过 5000 时启用文本框
- javascript - 如何根据下拉选择填充文本框?
- ios - UITapGesture 在 Popup 类上无法按预期工作
- c# - ContentPresenter - 水平对齐不起作用
- php - 正则表达式 - 在字符串中查找 8 位数字
- php - Laravel 验证是否已经存在具有相似两列组合的记录