By using a rake task you allow rake
to figure out if the check is needed or
not. For example, you may need to check if multiple tasks that are
dependencies of each other are running inside Docker
If you use a method to perform the check it will run every time for every task. This reduces performance because you really only need to run this check once.
If you use a task as a precondition instead rake
will determine when it
needs to run and only run it once.