174

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?

Oliver
  • 3,981
  • 2
  • 21
  • 35

3 Answers3

332

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.

larsks
  • 277,717
  • 41
  • 399
  • 399
  • 4
    I've came here when trying to run `service php7-fpm start`. It would return 1 and RUN would fail; using `service php7-fpm start; service php7-fpm status` does the trick - it seems to solve a problem during build as well, since both commands running separate would give trouble. – igorsantos07 Aug 22 '15 at 22:01
  • I've come here when trying to build Qt5 from source. It would build just fine, but using concurrent build combined with the fact that Qt build process has build-time tests run from make (that intentionally fail) my RUN command exited with error (2). This hopefully will solve the problem! – Mr. Developerdude Apr 30 '16 at 00:59
  • Ah Laravel composer install now forcing people to run... whatever.. – Benyamin Limanto Nov 03 '21 at 10:33
  • 1
    What if we want to use `COPY` instead of `RUN`?! For example, ignoring that the src/dest file exists or not. – mohammad hosein bahmani Nov 24 '21 at 13:11
  • Copy the parent directory of your file/directory into the container, then use a script in a `RUN` statement to check for specific files and place them where appropriate. – larsks Nov 24 '21 at 18:19
65

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

mths
  • 807
  • 8
  • 11
  • 2
    This is waaay underrated answer. My use case was some package lists not reachable and `apt-get update -y` was failing. – Silviu Burcea Mar 20 '20 at 09:53
52

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>
MortenB
  • 2,749
  • 1
  • 31
  • 35
  • 3
    just what i needed :) what would be even more better is to fail if job failed, but after next stage (cleanup) – csomakk Jan 14 '20 at 14:44
  • 1
    I actually need that because I know that specific job (dpkg) will fail, and the next step 'apt-get install -f' will fix all the missing dependencies. – Ben L Feb 03 '23 at 19:32