Docker构建不显示命令的任何输出

时间:2020-11-12 13:23:57

标签: docker docker-build

dockerfile中的代码段

FROM node:12.18.0
RUN echo "hello world"
RUN psql --version

运行docker build .时,即使未缓存这两个命令,也看不到任何输出。该文档说docker build在默认情况下是冗长的。为什么我看不到命令​​的输出?我以前看过他们。

构建时的输出:enter image description here 构建完成后,我看到的输出为:enter image description here

Dockerfile是从基于Debian 9的node:12.18.0创建的

Docker版本19.03.13,内部版本4484c46d9d。

3 个答案:

答案 0 :(得分:10)

只需在 --progress=plain 之后使用此标志 build

例如:

docker-compose build --progress=plain <container_name>

docker build --progress=plain .

这是您输入 docker build --help 时的官方文档。

--progress string         Set type of progress output (auto, plain, tty). Use plain to show container output (default "auto")

答案 1 :(得分:3)

作为指定 --progress=plain 选项的替代方法,您还可以通过在 shell 配置中设置此环境变量来永久禁用“漂亮”输出:

export BUILDKIT_PROGRESS=plain

答案 2 :(得分:2)

您显示的输出来自buildkit,它是docker附带的经典构建引擎的替代品。您可以使用--progress选项调整输出:

  --progress string         Set type of progress output (auto, plain, tty). Use plain to show container output
                            (default "auto")

添加--progress=plain将显示未从缓存加载的运行命令的输出。