Reduce output from docker build

Viewed 778

Is it possible to reduce the output from docker build so that warnings etc are still shown, but not the very verbose default output such as the below?

I have a script that builds 15 images and it just becomes useless to follow the outcome of it. If everything is OK I want no output, but I do want the warnings.

The --quiet flag to docker build removes everything. I also tried redirecting stdout to /dev/null but keeping stderr, but then also warnings are suppressed (for example warnings from optional modules using node-gyp failing due to missing python etc - I do want to see those).

Is there any way to only log warnings?

Example output to exclude:

 docker build: fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
 docker build: fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
 docker build: (1/27) Installing make (4.2.1-r2)
 docker build: (2/27) Installing binutils (2.33.1-r0)
 docker build: (3/27) Installing gmp (6.1.2-r1)
 docker build: (4/27) Installing isl (0.18-r0)
 docker build: (5/27) Installing libgomp (9.3.0-r0)
 [ ... ]
 docker build: OK: 232 MiB in 43 packages
 docker build: fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
 docker build: fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
 docker build: OK: 232 MiB in 43 packages
 docker build: fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz

Example output to include:

 docker build: warning Error running install script for optional dependency: "/usr/app/node_modules/unix-dgram: Command failed.

 docker build: gyp ERR! find Python 
 docker build: gyp ERR! find Python Python is not set from command line or npm configuration

Perhaps the node-gyp module is simply the culprit using stdout for warnings/errors?

Is there any better bet than piping through grep -E -i "warn|err" and hoping all relevant warnings are prefixed?

0 Answers
Related