Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker build colored messages unreadable

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

like image 344
Josef B. Avatar asked Mar 11 '21 14:03

Josef B.


3 Answers

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

like image 120
BMitch Avatar answered Oct 19 '22 19:10

BMitch


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

for example,

docker build -t getting-started . --progress plain
like image 22
kishore Avatar answered Oct 19 '22 20:10

kishore


Another ev option

export BUILDKIT_PROGRESS=plain
like image 4
notzippy Avatar answered Oct 19 '22 20:10

notzippy