如何查看 docker 构建 "RUN command" 标准输出? (docker 对于 windows)
How to see docker build "RUN command" stdout? (docker for windows)
过去我可以简单地做这样的事情:
Dockerfile
:
FROM ubuntu
RUN echo "test"
这会将 test
输出到我的 shell。我用它来调试我的构建。
在 docker 的最新稳定版本中,windows 的构建输出看起来完全不同,没有显示来自任何命令的任何标准输出。
如何查看构建过程中任何命令的输出?
以上 Dockerfile
示例的当前输出如下所示:
[+] Building 4.7s (6/6) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 65B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:latest 2.0s
=> [1/2] FROM docker.io/library/ubuntu@sha256:c95a8e48bf88e9849f3e0f723d9f49fa12c5a00cfc6e60d2bc99d87555295e4c 2.3s
=> => resolve docker.io/library/ubuntu@sha256:c95a8e48bf88e9849f3e0f723d9f49fa12c5a00cfc6e60d2bc99d87555295e4c 0.0s
=> => sha256:f643c72bc25212974c16f3348b3a898b1ec1eb13ec1539e10a103e6e217eb2f1 3.32kB / 3.32kB 0.0s
=> => sha256:da7391352a9bb76b292a568c066aa4c3cbae8d494e6a3c68e3c596d34f7c75f8 28.56MB / 28.56MB 1.2s
=> => sha256:14428a6d4bcdba49a64127900a0691fb00a3f329aced25eb77e3b65646638f8d 847B / 847B 0.5s
=> => sha256:c95a8e48bf88e9849f3e0f723d9f49fa12c5a00cfc6e60d2bc99d87555295e4c 1.20kB / 1.20kB 0.0s
=> => sha256:4e4bc990609ed865e07afc8427c30ffdddca5153fd4e82c20d8f0783a291e241 943B / 943B 0.0s
=> => extracting sha256:da7391352a9bb76b292a568c066aa4c3cbae8d494e6a3c68e3c596d34f7c75f8 0.8s
=> => extracting sha256:14428a6d4bcdba49a64127900a0691fb00a3f329aced25eb77e3b65646638f8d 0.0s
=> => extracting sha256:2c2d948710f21ad82dce71743b1654b45acb5c059cf5c19da491582cef6f2601 0.0s
=> [2/2] RUN echo "test" 0.3s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:8c61a015c1cc5af925e0db03bb56a627ce3624818c456fca11379c92c2e9d864 0.0s
通读
更改输出格式的原因是现在使用名为“buildkit”的新功能而不是“经典”docker构建。
方法一(取自上述问题答案)
使用docker build --progress=plain .
查看普通输出。
要永久设置进度到普通ENVBUILDKIT_PROGRESS=plain
可以设置。
为了快速获胜(非永久性),我只是将以下行添加到脚本的开头:
- powershell:
$env:BUILDKIT_PROGRESS="plain"
- 命令:
set BUILDKIT_PROGRESS=plain
方法二(不推荐)
在设置中禁用 buildkit docker 引擎功能
过去我可以简单地做这样的事情:
Dockerfile
:
FROM ubuntu
RUN echo "test"
这会将 test
输出到我的 shell。我用它来调试我的构建。
在 docker 的最新稳定版本中,windows 的构建输出看起来完全不同,没有显示来自任何命令的任何标准输出。
如何查看构建过程中任何命令的输出?
以上 Dockerfile
示例的当前输出如下所示:
[+] Building 4.7s (6/6) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 65B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:latest 2.0s
=> [1/2] FROM docker.io/library/ubuntu@sha256:c95a8e48bf88e9849f3e0f723d9f49fa12c5a00cfc6e60d2bc99d87555295e4c 2.3s
=> => resolve docker.io/library/ubuntu@sha256:c95a8e48bf88e9849f3e0f723d9f49fa12c5a00cfc6e60d2bc99d87555295e4c 0.0s
=> => sha256:f643c72bc25212974c16f3348b3a898b1ec1eb13ec1539e10a103e6e217eb2f1 3.32kB / 3.32kB 0.0s
=> => sha256:da7391352a9bb76b292a568c066aa4c3cbae8d494e6a3c68e3c596d34f7c75f8 28.56MB / 28.56MB 1.2s
=> => sha256:14428a6d4bcdba49a64127900a0691fb00a3f329aced25eb77e3b65646638f8d 847B / 847B 0.5s
=> => sha256:c95a8e48bf88e9849f3e0f723d9f49fa12c5a00cfc6e60d2bc99d87555295e4c 1.20kB / 1.20kB 0.0s
=> => sha256:4e4bc990609ed865e07afc8427c30ffdddca5153fd4e82c20d8f0783a291e241 943B / 943B 0.0s
=> => extracting sha256:da7391352a9bb76b292a568c066aa4c3cbae8d494e6a3c68e3c596d34f7c75f8 0.8s
=> => extracting sha256:14428a6d4bcdba49a64127900a0691fb00a3f329aced25eb77e3b65646638f8d 0.0s
=> => extracting sha256:2c2d948710f21ad82dce71743b1654b45acb5c059cf5c19da491582cef6f2601 0.0s
=> [2/2] RUN echo "test" 0.3s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:8c61a015c1cc5af925e0db03bb56a627ce3624818c456fca11379c92c2e9d864 0.0s
通读
方法一(取自上述问题答案)
使用docker build --progress=plain .
查看普通输出。
要永久设置进度到普通ENVBUILDKIT_PROGRESS=plain
可以设置。
为了快速获胜(非永久性),我只是将以下行添加到脚本的开头:
- powershell:
$env:BUILDKIT_PROGRESS="plain"
- 命令:
set BUILDKIT_PROGRESS=plain
方法二(不推荐)
在设置中禁用 buildkit docker 引擎功能