diff --git a/src/rocker/core.py b/src/rocker/core.py index 515a601a..8eb7a264 100644 --- a/src/rocker/core.py +++ b/src/rocker/core.py @@ -136,7 +136,7 @@ def get_docker_client(): def docker_build(docker_client = None, output_callback = None, **kwargs): image_id = None build_success = False - build_output = [] + error_message = [] if not docker_client: docker_client = get_docker_client() @@ -149,17 +149,20 @@ def docker_build(docker_client = None, output_callback = None, **kwargs): continue if output_callback is not None: output_callback(output) - build_output.append(output) match = re.match(r'Successfully built ([a-z0-9]{12})', output) if match: image_id = match.group(1) build_success = True + elif "error" in output.lower(): + error_message.append(output) + if build_success: return image_id else: - raise Exception("Build failed: "+"\n".join(build_output)) + error_msg = "\n".join(error_message) + raise Exception(f"Build failed:\n{error_msg}") class SIGWINCHPassthrough(object):