Docker 构建彩色消息不可读

Docker build colored messages unreadable

我在 Windows 10 上使用 'docker build' 构建 asp 网络核心网络应用程序图像。但是,自上次更新以来,消息的颜色变得难以阅读。在互联网上搜索没有提供任何答案。
关于如何解决这个问题的任何想法?

使用 docker,您可以将 --help 选项传递给命令以查看用法。例如:

$ docker build --help

Usage:  docker build [OPTIONS] PATH | URL | -

Build an image from a Dockerfile

Options:
      --add-host list           Add a custom host-to-IP mapping (host:ip)
      --build-arg list          Set build-time variables
      --cache-from strings      Images to consider as cache sources
      --disable-content-trust   Skip image verification (default true)
  -f, --file string             Name of the Dockerfile (Default is 'PATH/Dockerfile')
      --iidfile string          Write the image ID to the file
      --isolation string        Container isolation technology
      --label list              Set metadata for an image
      --network string          Set the networking mode for the RUN instructions during build (default "default")
      --no-cache                Do not use cache when building the image
  -o, --output stringArray      Output destination (format: type=local,dest=path)
      --platform string         Set platform if server is multi-platform capable
      --progress string         Set type of progress output (auto, plain, tty). Use plain to show container output (default "auto")
      --pull                    Always attempt to pull a newer version of the image
  -q, --quiet                   Suppress the build output and print image ID on success
      --secret stringArray      Secret file to expose to the build (only if BuildKit enabled): id=mysecret,src=/local/secret
      --squash                  Squash newly built layers into a single new layer
      --ssh stringArray         SSH agent socket or keys to expose to the build (only if BuildKit enabled) (format: default|<id>[=<socket>|<key>[,<key>]])                                                                                                                     
  -t, --tag list                Name and optionally a tag in the 'name:tag' format
      --target string           Set the target build stage to build.

要关闭彩色输出,您可以设置 --progress plain 删除彩色格式化文本和其他 tty 功能,例如更新每个构建步骤的时间。

或者,您可能只想更改终端的颜色。黑色和白色都很好用。但是蓝色背景会与蓝色文字冲突。


另一个选项是禁用 buildkit 并恢复到经典构建引擎。这可以通过环境变量来完成:

export DOCKER_BUILDKIT=0

或在/etc/docker/daemon.json中配置默认​​值:

{
  "features": {"buildkit": false }
}

但是,经典构建器将不支持添加到 buildkit 的功能,并且不太可能看到更多的发展。

只需在 运行 docker build 命令的最后添加标志 --progress plain

例如,

docker build -t getting-started . --progress plain

另一个 ev 选项

export BUILDKIT_PROGRESS=plain