尝试从 Ubuntu 18.04 基础镜像构建 Docker 镜像,但卡在“配置 tzdata”

尝试从 Ubuntu 18.04 基础镜像构建 Docker 镜像,但卡在“配置 tzdata”

我正在尝试从以下dockerfile构建docker镜像:

FROM ubuntu:18.04

# Install Python
RUN apt-get update && apt-get install -y python3.10 python3-pip

# Install Java
RUN apt-get update && apt-get install -y openjdk-8-jdk

# Install Bowtie2
RUN apt-get update && apt-get install -y bowtie2

RUN apt-get update && \
apt-get install --yes --no-install-recommends \
zlib1g-dev \
libbz2-dev \
liblzma-dev \
&& rm -rf /var/lib/apt/lists/*

# Install RSeQC
RUN apt-get update && apt-get install -y python-pip
RUN pip install RSeQC

# Install biopython=1.80
RUN pip install biopython

# Install Atria
RUN apt-get update && apt-get install -y wget
RUN wget https://github.com/cihga39871/Atria/releases/download/v3.1.2/atria-3.1.2-linux.tar.gz
RUN tar -zxf atria-3.1.2-linux.tar.gz
RUN mv atria-3.1.2/bin/atria /usr/local/bin/atria
RUN chmod +x /usr/local/bin/atria

##Atria dependencies
RUN apt-get update && apt-get install pigz pbzip2

# Install findtail
RUN apt-get update && apt-get install -y wget
RUN wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/findtail/findtail_v1.01
RUN mv findtail_v1.01 /usr/local/bin/findtail_v1.01
RUN chmod +x /usr/local/bin/findtail_v1.01

当我尝试构建图像时,它卡在了:

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

它一直卡在那里,直到我按下 ctrl+c。知道为什么会发生这种情况吗?

答案1

您需要稍微修改 Dockerfile。apt update一开始需要做一次。Tzdata 是作为依赖项安装的,配置不起作用。使用以下行

RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata. 

您需要采用时区。

最后你的dockerfile可能看起来像:


FROM ubuntu:20.04

# Install tzdata
RUN apt-get update &&\
    DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata

# Install Python, Bowtie2 and Java
RUN apt-get install -y python3.10 python3-pip \ 
    openjdk-8-jdk  \ 
    bowtie2 \ 
    wget

RUN  apt-get install --yes --no-install-recommends \
     zlib1g-dev \
     libbz2-dev \
     liblzma-dev  

# Install RSeQC
RUN pip install RSeQC

# Install biopython=1.80
RUN pip install biopython

# Install Atria
RUN wget https://github.com/cihga39871/Atria/releases/download/v3.1.2/atria-3.1.2-linux.tar.gz && \
    tar -zxf atria-3.1.2-linux.tar.gz && \
    mv atria-3.1.2/bin/atria /usr/local/bin/atria && \
    chmod +x /usr/local/bin/atria

#Atria dependencies
RUN  apt-get install pigz pbzip2

# Install findtail
 RUN wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/findtail/findtail_v1.01 && \
     mv findtail_v1.01 /usr/local/bin/findtail_v1.01 && \
     chmod +x /usr/local/bin/findtail_v1.01 
# Cleanup 
RUN apt clean

并归功于如何在 ubuntu-docker 镜像上安装 tzdata

相关内容