Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git `docker build`根据安装顺序挂起_Git_Docker_Ubuntu_Cmake - Fatal编程技术网

Git `docker build`根据安装顺序挂起

Git `docker build`根据安装顺序挂起,git,docker,ubuntu,cmake,Git,Docker,Ubuntu,Cmake,鉴于此Dockerfile: FROM ubuntu:20.04 RUN set -ex && apt-get update RUN set -ex && \ apt-get install -y \ git RUN set -ex && \ apt-get install -y \ cmake ENV HOME_DIR /home/develop WORKDIR ${HOME_DIR} ENV TZ=A

鉴于此
Dockerfile

FROM ubuntu:20.04

RUN set -ex && apt-get update

RUN set -ex && \
    apt-get install -y \
    git

RUN set -ex && \
    apt-get install -y \
    cmake

ENV HOME_DIR /home/develop

WORKDIR ${HOME_DIR}
ENV TZ=America/Los_Angeles
RUN ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime
RUN echo "$TZ" > /etc/timezone

RUN apt-get update
RUN apt-get install -y tzdata
docker构建
挂起配置
tzdata

$ DOCKER_BUILDKIT=0 docker build -f Docker/Dockerfile -t cmake:latest .
Sending build context to Docker daemon  161.8kB
Step 1/6 : FROM ubuntu:20.04
 ---> 7e0aa2d69a15
Step 2/6 : RUN set -ex && apt-get update
 ---> Using cache
 ---> 78e8a28063b0
Step 3/6 : RUN set -ex &&     apt-get install -y    git
 ---> Using cache
 ---> d400fc509ae8
Step 4/6 : RUN set -ex &&     apt-get install -y    cmake
 ---> Running in 2c58632e70a3
+ apt-get install -y cmake
Reading package lists...
Building dependency tree...
Reading state information...
...
Setting up tzdata (2021a-0ubuntu0.20.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: 
如果我颠倒
git
cmake
的顺序,它将成功构建。为什么订单很重要


我正在MacOS 11(Big Sur)上运行Docker 20.10.5。

在安装之前,CMake包必须为
tzdata
自动选择默认选项(作为git的依赖项)。奇怪,但解决办法很简单。在
Dockerfile
顶部附近添加以下行:

FROM ubuntu:20.04

RUN set -ex && apt-get update

RUN set -ex && \
    apt-get install -y \
    git

RUN set -ex && \
    apt-get install -y \
    cmake

ENV HOME_DIR /home/develop

WORKDIR ${HOME_DIR}
ENV TZ=America/Los_Angeles
RUN ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime
RUN echo "$TZ" > /etc/timezone

RUN apt-get update
RUN apt-get install -y tzdata

当然,将
America/Los_Angeles
替换为您认为最适合您的应用程序的时区,可能
UTC

在安装之前,CMake软件包必须为
tzdata
自动选择默认选项(作为git的依赖项?)。奇怪,但解决办法很简单。在
Dockerfile
顶部附近添加以下行:

FROM ubuntu:20.04

RUN set -ex && apt-get update

RUN set -ex && \
    apt-get install -y \
    git

RUN set -ex && \
    apt-get install -y \
    cmake

ENV HOME_DIR /home/develop

WORKDIR ${HOME_DIR}
ENV TZ=America/Los_Angeles
RUN ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime
RUN echo "$TZ" > /etc/timezone

RUN apt-get update
RUN apt-get install -y tzdata

当然,用您认为最适合您的应用程序的时区替换
America/Los_Angeles
,可能是
UTC

Git将perl作为其依赖项之一安装,同时安装
Term::ReadLine
perl模块。使用此模块,在安装cmake时,debconf可以初始化
读线
前端,并可以等待输入。但是,如果您首先安装cmake,该模块在本地还不存在,并且debconf将无法设置tzdata,并将使用默认配置

如果我们先安装cmake,则日志可以证明上述情况:

Setting up tzdata (2021a-0ubuntu0.20.04) ...
[243/1270]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: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
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:
Use of uninitialized value $_[1] in join or string at /usr/share/perl5/Debconf/DbDriver/Stack.pm line 111.
Current default time zone: '/UTC'
Local time is now:      Sat May  8 21:19:41 UTC 2021.
Universal Time is now:  Sat May  8 21:19:41 UTC 2021.
Run 'dpkg-reconfigure tzdata' if you wish to change it.

Git将perl作为其依赖项之一安装,并安装
Term::ReadLine
perl模块。使用此模块,在安装cmake时,debconf可以初始化
读线
前端,并可以等待输入。但是,如果您首先安装cmake,该模块在本地还不存在,并且debconf将无法设置tzdata,并将使用默认配置

如果我们先安装cmake,则日志可以证明上述情况:

Setting up tzdata (2021a-0ubuntu0.20.04) ...
[243/1270]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: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
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:
Use of uninitialized value $_[1] in join or string at /usr/share/perl5/Debconf/DbDriver/Stack.pm line 111.
Current default time zone: '/UTC'
Local time is now:      Sat May  8 21:19:41 UTC 2021.
Universal Time is now:  Sat May  8 21:19:41 UTC 2021.
Run 'dpkg-reconfigure tzdata' if you wish to change it.

通过设置DEBIAN_FRONTEND变量来抑制apt的提示,该变量可通过仅在构建期间存在的构建参数来完成(允许交互式用户执行到容器中):


另外,请注意,更新应与安装步骤一起运行,以避免过时缓存破坏生成。

通过设置DEBIAN_FRONTEND变量来抑制apt的提示,该变量可以使用仅在生成期间存在的生成参数来完成(允许交互用户执行到容器中):

另外,请注意,更新应该与安装步骤一起运行,以避免过时缓存破坏构建