18

I am using 'docker build' on Windows 10 to build asp net core web app image. However, since the last update, messages are colored in such a way that it gets unreadable. Searching on the internet did not provide any answers.
Any ideas on how to get around this? enter image description here

Pawara Siriwardhane
  • 1,873
  • 10
  • 26
  • 38
Josef B.
  • 414
  • 4
  • 9

3 Answers3

12

[Updated 2022-08-02]

As of PR #2954 (which may take a bit to get released into Docker Desktop), you can run:

export NO_COLOR=1

There have also been changes to make the default text colors more readable.


[Original answer]

With docker, you can pass the --help option to a command to see usage. E.g.:

$ 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.

For turning off the colored output, you can set --progress plain which removes the color formatted text and other tty features like updating the time for each build step. You can make this the default with:

export BUILDKIT_PROGRESS=plain

Alternatively, you may just want to change the color of your terminal. Black and white both work nicely. But a bluish background will clash with the blue text.


The other option is to disable buildkit and revert back to the classic build engine. That can be done with an environment variable:

export DOCKER_BUILDKIT=0

or configuring the default in /etc/docker/daemon.json:

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

However, the classic builder will not support features being added to buildkit and is unlikely to see much development going forward.

BMitch
  • 231,797
  • 42
  • 475
  • 450
  • Thx a lot, works. I did read the docs but, probably i overlooked this. Seems to be some secret .... – Josef B. Mar 11 '21 at 15:15
  • 1
    I don't have a bluish background on my terminal, but I do have a slightly transparent background, and as a result I find the blue next almost unreadable even when the actual terminal background colour is black. I can do `--progress plain`, but then I'm giving up the other tty features that I like. As well, our build scripts that do a `docker build` are in source control, so to add that switch I have to modify a source controlled file, then make sure I don't commit that change. I really wish there was just an env var you could set to have the same effect as the switch. :shrug: – Adam Parkin Apr 16 '21 at 17:42
  • 1
    @AdamParkin you could also disable buildkit, but I wouldn't recommend that. I also managed to get buildkit to default back to plain mode by adjusting stdin/stdout/stderr to not be the terminal. Not sure if there's a cleaner way: `docker build . &1 | cat` – BMitch Apr 16 '21 at 18:31
  • Where do I add ```export NO_COLOR=1```? – Daniel Jun 26 '23 at 12:50
6

Just add flag --progress plain while running docker build command, in the last.

for example,

docker build -t getting-started . --progress plain
Hari Kishore
  • 2,201
  • 2
  • 19
  • 28
5

Another ev option

export BUILDKIT_PROGRESS=plain
notzippy
  • 468
  • 7
  • 10