Search code examples
dockerjenkins-docker

Skip error in dockerfile during the build


Just wonder if theres a better way to skip a command that could fail (because I'm using jenkins to build and deploy the application)

Now I'm doing something like this

RUN unlink /run/supervisor.sock && etc/init.d/supervisor stop || echo "supervisor was not started"

Solution

  • this is a typical linux trick to ensure a zero exit code

    RUN unlink /run/supervisor.sock && etc/init.d/supervisor stop || :
    

    the answer given here essentially uses different syntax to achieve the same

    Dockerfile build - possible to ignore error?

    there is no other way of preventing build failure at present