【问题标题】:Why aren't all of my Docker commands executing during build?为什么我的所有 Docker 命令在构建期间都没有执行?
【发布时间】:2021-09-28 10:29:33
【问题描述】:

编辑:我想通了:我在没有运行命令的情况下构建了容器,并且似乎它已将 miniconda 下载为带有空格的“Miniconda.sh”-.- 所以我的所有其他命令都丢失了。谢谢!

这是我的 Dockerfile。

#
# Building a docker image with the latest ubuntu version and basic python install
#
# latest ubuntu version
FROM ubuntu:latest

# information about maintainer
MAINTAINER yves

# add the bash script
ADD install.sh /
# change rights for the script
RUN chmod u+x /install.sh
# run the bash script
RUN /install.sh
# prepend the new path
ENV PATH /root/miniconda3/bin:$PATH

# execute IPython when container is run
CMD ["ipython"]

当我构建时

docker build -t pyalgo:basic .

但是,它在日志中显示并非每个命令都在执行。

日志中只执行了四个命令:

 => CACHED [1/4] FROM docker.io/library/ubuntu:latest                                                                                                          0.0s
 => [2/4] ADD install.sh /                                                                                                                                     0.0s
 => [3/4] RUN chmod u+x /install.sh                                                                                                                            0.3s
 => [4/4] RUN /install.sh 

我试图找出为什么会发生这种情况,但我不明白。它似乎正在查找文件和所有内容。

编辑:我尝试使用以下关于 --progress 的建议,但它似乎仍然只使用 4 个命令: enter image description here

【问题讨论】:

  • @GinoMempin 我尝试显示更多输出,但这似乎不是输出问题,因为使用 --progress=plain 仍然只显示 4 个命令
  • 您是否希望 MAINTAINER 和最后一个 CMD 也会显示?

标签: docker docker-build


【解决方案1】:

Docker 现在默认使用 BuildKit 来构建 Linux 容器。

如果您想查看所有构建步骤,您可以在 BuildKit 中使用--progress

docker build --progress=plain ...

或者,您可以要求 Docker 使用经典构建器而不是 BuildKit:

DOCKER_BUILDKIT=0 docker build ...

【讨论】:

  • 我怀疑它没有执行所有步骤,因为应该安装的东西没有。我尝试使用 --progress 标签,但似乎仍然只执行了 4 个步骤。
  • 您使用的完整命令是什么?您是否尝试过第二个命令?
【解决方案2】:

编辑:我想通了:我在没有运行命令的情况下构建了容器,并且似乎它已将 miniconda 下载为带有空格的“Miniconda.sh”-.- 所以我的所有其他命令都丢失了。谢谢!

【讨论】:

    猜你喜欢
    • 2021-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-17
    • 2023-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多