首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在ubuntu码头映像上安装tzdata?

如何在ubuntu码头映像上安装tzdata?
EN

Server Fault用户
提问于 2019-01-21 01:50:55
回答 8查看 178.5K关注 0票数 196

我在Dockerfile中有下面一行。

代码语言:javascript
复制
RUN apt-get install -y tzdata

当我运行它时,它需要我的输入。在我提供了我的意见之后,它就挂在那里了。有人知道如何解决这个问题吗?

代码语言:javascript
复制
Step 25/25 : RUN apt-get install -y tzdata
 ---> Running in ee47a1beff84
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  tzdata
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 189 kB of archives.
After this operation, 3104 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 tzdata all 2018i-0ubuntu0.18.04 [189 kB]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin: 
Fetched 189 kB in 1s (219 kB/s)
Selecting previously unselected package tzdata.
(Reading database ... 25194 files and directories currently installed.)
Preparing to unpack .../tzdata_2018i-0ubuntu0.18.04_all.deb ...
Unpacking tzdata (2018i-0ubuntu0.18.04) ...
Setting up tzdata (2018i-0ubuntu0.18.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:
``
EN

回答 8

Server Fault用户

回答已采纳

发布于 2019-11-19 13:11:05

只有一行:

代码语言:javascript
复制
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
票数 208
EN

Server Fault用户

发布于 2020-05-13 14:21:55

您可以使用ARGENV指令来发挥您的优势:

代码语言:javascript
复制
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Moscow
RUN apt-get install -y tzdata

这样,只有在构建映像时才定义DEBIAN_FRONTEND,而TZ将在运行时持久化。

票数 113
EN

Server Fault用户

发布于 2019-01-21 03:28:22

您需要执行一系列命令:

代码语言:javascript
复制
    # set noninteractive installation
    export DEBIAN_FRONTEND=noninteractive
    # install tzdata package
    apt-get install -y tzdata
    # set your timezone
    ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime
    dpkg-reconfigure --frontend noninteractive tzdata

(以#开头的命令是注释,您可以忽略它们)

最好的方法是创建脚本,将脚本复制到容器并在Dockerfile中执行它:

代码语言:javascript
复制
ADD yourscript.sh /yourscript.sh
RUN /yourscript.sh
票数 53
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/949991

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档