apache/kafka · error · SystemError

Docker Image Build failed

Error message

Docker Image Build failed

What it means

docker/common.py:build_docker_image_runner wraps execute(command.split()) in a bare `except:` and re-raises SystemError('Docker Image Build failed'). The bare except discards the underlying error entirely (no chaining, no message), so this is a lossy wrapper. It also cleans up the temp dir in a `finally`.

Solutions

  1. Re-run the exact `docker buildx build ...` command from the script output manually to see the real stderr.
  2. Verify the kafka archive URL is reachable and the build args are correct.
  3. Clear buildx cache: `docker buildx prune -f`.
  4. Patch the script locally to drop the bare except (or `raise ... from e`) so the cause is preserved.

Example fix

# before (library)
try:
    execute(command.split())
except:
    raise SystemError("Docker Image Build failed")  # cause lost

# local debug
$ docker buildx build -f <DOCKERFILE> --build-arg kafka_url=<url> --build-arg build_date=$(date +%F) <DIR>
# real error printed to stderr

# suggested fix (if you control the script)
except Exception as e:
    raise SystemError("Docker Image Build failed") from e
Defensive patterns

Strategy: try-catch

Validate before calling

null  # validate by running the same docker buildx build manually first

Type guard

null

Try / catch

try:
    build_docker_image_runner(cmd, image_type, kafka_archive)
except SystemError as e:
    print("Build failed; re-running for diagnostics:", ' '.join(cmd.split()), file=sys.stderr)
    subprocess.run(cmd.split())  # surface real stderr
    raise

Prevention

When it happens

Trigger: The docker buildx build subprocess (for native or jvm image types) returns non-zero, causing execute() to raise, which the bare except re-wraps.

Common situations: Dockerfile syntax error; missing build arg (kafka_url, build_date); network failure fetching the kafka archive; buildx cache corruption; out-of-disk-space during the build.

Related errors


AI-assisted analysis of apache/kafka@996fb4585a (2026-08-11). Data as JSON: /api/errors/240b9bbf94104f92. Report an issue: GitHub.

Appendix: source

Thrown at docker/common.py:46

    value = input(message)
    if value == "":
        raise ValueError("This field cannot be empty")
    return value

def build_docker_image_runner(command, image_type, kafka_archive=None):
    temp_dir_path = tempfile.mkdtemp()
    current_dir = os.path.dirname(os.path.realpath(__file__))
    shutil.copytree(f"{current_dir}/{image_type}", f"{temp_dir_path}/{image_type}", dirs_exist_ok=True)
    shutil.copytree(f"{current_dir}/resources", f"{temp_dir_path}/{image_type}/resources", dirs_exist_ok=True)
    shutil.copy(f"{current_dir}/server.properties", f"{temp_dir_path}/{image_type}")
    if kafka_archive:
        shutil.copy(kafka_archive, f"{temp_dir_path}/{image_type}/kafka.tgz")
    command = command.replace("$DOCKER_FILE", f"{temp_dir_path}/{image_type}/Dockerfile")
    command = command.replace("$DOCKER_DIR", f"{temp_dir_path}/{image_type}")
    try:
        execute(command.split())
    except:
        raise SystemError("Docker Image Build failed")
    finally:
        shutil.rmtree(temp_dir_path)

View on GitHub (pinned to 996fb4585a)