[Docker] 使用ubuntu涉及时区问题

不多说,以下Dockerfile会报错

复制代码
FROM ubuntu:latest

RUN apt-get update && apt-get install -y \
    ssh \
    build-essential \
    gcc \
    g++ \
    gdb \
    clang \
    cmake \
    rsync \
    tar \
    python \
    vim \
    automake \
    openssh-client \
    openssh-server \
  && apt-get clean

RUN PermitRootLogin yes \
  && UsePAM no

RUN passwd root

COPY entrypoint.sh /sbin
RUN chmod +x /sbin/entrypoint.sh
ENTRYPOINT [ "/sbin/entrypoint.sh" ]
复制代码

会卡在这里

复制代码
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:
复制代码

即使输入了6,还是僵死在那里。

 

解决方案:加入以下代码

RUN export DEBIAN_FRONTEND=noninteractive \
    && apt-get update \
    && apt-get install -y tzdata \
    && ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && dpkg-reconfigure --frontend noninteractive tzdata

 

Have fun with Docker!

 

posted @   DavidHHuan  阅读(2958)  评论(2编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· [AI/GPT/综述] AI Agent的设计模式综述
历史上的今天:
2010-07-02 [Ubuntu] 利用Ubuntu光盘破解win7用户登录 -- Crark the win7 user via Ubuntu live CD
点击右上角即可分享
微信分享提示