Dockerfile build - possible to ignore error?

DockerDockerfile

Docker Problem Overview


I've got a Dockerfile. When building the image, the build fails on this error:

automake: error: no 'Makefile.am' found for any configure output
Error build: The command [/bin/sh -c aclocal && autoconf && automake -a] returned a non-zero code: 1

which in reality is harmless. The library builds fine, but Docker stops the build once it receives this error. Is there any way I can instruct Docker to just ignore this?

Docker Solutions


Solution 1 - Docker

Sure. Docker is just responding to the error codes returned by the RUN shell scripts in the Dockerfile. If your Dockerfile has something like:

RUN make

You could replace that with:

RUN make; exit 0

This will always return a 0 (success) exit code. The disadvantage here is that your image will appear to build successfully even if there are actual errors in the build process.

Solution 2 - Docker

This might be of interest to those, whose potential errors in their images are not harmless enough to go unnoticed/logged. (Also, not enough rep. to comment, so here as an answer.)

As pointed out, the disadvantage of RUN make; exit 0 is you don't get to know, if your build failed. Hence, rather use something like:

make test 2>&1 > /where/ever/make.log || echo "There were failing tests!"

Like this, you get notified via the docker image build process log, and you can see what exactly went bad during make (or whatsoever else execution, this is not restricted to make).

Solution 3 - Docker

You can also use the standard bash ignore error || true, which is nice if you are in the middle of a chain:

RUN <first stage> && <job that might fail> || true && <next stage>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionOskarView Question on Stackoverflow
Solution 1 - DockerlarsksView Answer on Stackoverflow
Solution 2 - DockermthsView Answer on Stackoverflow
Solution 3 - DockerMortenBView Answer on Stackoverflow