【发布时间】:2018-08-31 04:05:02
【问题描述】:
概要
我正在尝试构建 Docker 映像,但它失败了,因为我尝试使用 apt install 获取的软件包之一在安装过程中提示用户。我想回复这个提示,但我不知道如何以非交互方式进行。
说明
我正在构建一个 Docker 映像,我的 Dockerfile 有以下行:
RUN apt install -y texlive-latex-extra
(这个包有一些我需要的 LaTeX 库。)
在安装过程中,这会停止:
Setting up tzdata (2018d-1) ...
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 6. Asia 11. System V timezones
2. America 7. Atlantic Ocean 12. US
3. Antarctica 8. Europe 13. None of the above
4. Australia 9. Indian Ocean
5. Arctic Ocean 10. Pacific Ocean
Geographic area:
此时,它正在等待一些输入。 (在此之后还有一个选择时区的提示——我认为这对于 LaTeX 文件中的 \today 指令很重要。¯\_(ツ)_/¯)
如何以非交互方式回答这个问题?
到目前为止我已经尝试过什么
我试过这样做:
apt install -y texlive-latex-extra <(echo 12 && echo 2)
还有这个:
echo 12 && echo 2 | apt install -y texlive-latex-extra
第一个死于此错误:
apt install -y texlive-latex-extra <(echo 12 && echo 9)
第二个好像没有效果。
作为参考,到目前为止,这是我的 Dockerfile:
FROM ubuntu:latest
RUN apt update && apt upgrade -y && apt install -y curl bzip2 tar make gcc wget gnupg unzip
RUN apt install -y texlive
RUN apt install -y nodejs npm git
RUN npm install -g bower
RUN apt install -y texlive-latex-extra
更新
我发现了一些接近 here 的内容,它建议将 apt install 与 DEBIAN_FRONTEND=noninteractive 一起运行。这充分解决了我的问题。 :) 但是,我仍然想知道如何响应提示,因为那里提供的解决方案只提供了如何抑制它们。
【问题讨论】:
标签: dockerfile apt tex-live