为什么 docker build 没有显示命令的任何输出? [英] Why is docker build not showing any output from commands?

查看:224
本文介绍了为什么 docker build 没有显示命令的任何输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自我的 Dockerfile 的片段:

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

当我运行 docker build . 时,我看不到这两个命令的任何输出,即使它们没有被缓存.文档说 docker build 默认是冗长的.为什么我看不到命令​​的输出?我以前见过他们.

When I run docker build . I don't see any output from these two commands even if they are not cached. The documentation says that docker build is verbose by default. Why am I not seeing the output from commands? I used to see them before.

构建时的输出:构建完成后我看到的输出:

The output while building: The output I am seeing after building finishes:

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

The Dockerfile is created from node:12.18.0 which is based on Debian 9.

Docker 版本 19.03.13,构建 4484c46d9d.

Docker version 19.03.13, build 4484c46d9d.

推荐答案

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

The output you are showing is from buildkit, which is a replacement for the classic build engine that docker ships with. You can adjust output from this with the --progress option:

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

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

Adding --progress=plain will show the output of the run commands that were no loaded from the cache.

如果您不想使用 buildkit,您可以通过在 shell 中导出 DOCKER_BUILDKIT=0 来恢复到旧的构建引擎,例如:

If you don't want to use buildkit, you can revert to the older build engine by exporting DOCKER_BUILDKIT=0 in your shell, e.g.:

DOCKER_BUILDKIT=0 docker build ...

export DOCKER_BUILDKIT=0
docker build ...

这篇关于为什么 docker build 没有显示命令的任何输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆