我正在构建一个基于 Ubuntu 18.04 的 Docker 镜像。 它构建正常,但在完成之前我在 Powershell 控制台中收到:
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:
----
据我了解,它等待我的一些答复,但我无法输入任何数字,即键盘上没有反应。如何避免这个问题呢?可能是我可以在 dockerfile 中添加 CMD 吗?
我在
Dockerfile
中遇到了同样的问题,然后我使用了
ARG DEBIAN_FRONTEND=noninteractive
在基本图像之后,它对我有用:
示例 Dockerfile:
FROM ubuntu
ARG DEBIAN_FRONTEND=noninteractive
这对我有用。
ENV TZ=Asia/Kolkata \
DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install tzdata
避免在 Docker 中使用
apt
,而是使用 apt-get
。 DEBIAN_FRONTEND=noninteractive 在 apt
上不起作用。
此外,还可以推荐一些需要此类输入的软件包。因此,在您的
--no-install-recommends
运行中添加 apt-get install -y
选项。例如
RUN export DEBIAN_FRONTEND=noninteractive && \
# To avoid the installation of non essential packages
apt-get install -yq --no-install-recommends \
wget git
使用 tzdata,我设置了以下环境变量以使其正常工作:
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Africa/Johannesburg