Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Apache Hudi Docker Prerequisites Verification

From Leeroopedia


Knowledge Sources
Domains DevOps, Development_Environment
Last Updated 2026-02-08 00:00 GMT

Overview

Concrete tool for verifying Docker and Docker Compose availability provided by Apache Hudi Docker demo.

Description

The Docker Prerequisites Verification is implemented primarily through the get_docker_compose_cmd() function defined in hudi-notebooks/run_spark_hudi.sh and through the implicit requirements documented in docker/README.md. The function detects whether Docker Compose v2 (the docker compose plugin) or v1 (the standalone docker-compose binary) is available on the system, and returns the appropriate command string for use by downstream scripts.

When neither variant is found, the function emits an error message to stderr and exits with a non-zero status code, preventing any subsequent Docker operations from executing in an undefined state. This detection is performed at script startup, before any containers are created or images are pulled.

Beyond the Compose detection, the broader prerequisites documented in the project README include Docker CLI, Maven (for source-based image builds), and a JDK installation. These are not programmatically verified but are required for the full demo workflow.

Usage

Use this verification:

  • At the beginning of any script that invokes Docker Compose commands
  • When debugging environment setup failures
  • When switching between Docker Desktop versions that may change Compose availability

Code Reference

Source Location

  • Repository: Apache Hudi
  • File: hudi-notebooks/run_spark_hudi.sh
  • Lines: 24-33
  • Additional Reference: docker/README.md lines 1-198

Script

get_docker_compose_cmd() {
    if docker compose version &>/dev/null; then
        echo "docker compose"
    elif docker-compose version &>/dev/null; then
        echo "docker-compose"
    else
        echo "ERROR: Neither 'docker compose' nor 'docker-compose' is installed or available in PATH." >&2
        exit 1
    fi
}

# Detect and assign the correct compose command
DOCKER_COMPOSE_CMD=$(get_docker_compose_cmd)

I/O Contract

Inputs

Name Type Required Description
Docker CLI System binary Yes The docker command must be installed and in the system PATH. Required for both docker compose (v2 plugin) detection and all container operations.
Docker Compose v1 or v2 System binary/plugin Yes (one of) Either the docker-compose standalone binary (v1) or the docker compose CLI plugin (v2) must be available. The function probes v2 first.
Maven System binary Conditional Required only when using build_local_docker_images.sh to build images from source. Not needed when pulling pre-built images from Docker Hub.
Java/JDK System runtime Conditional Required as a Maven dependency when building from source. Not needed for pre-built image workflows.

Outputs

Name Type Description
DOCKER_COMPOSE_CMD String (shell variable) Contains either "docker compose" or "docker-compose" depending on which variant was detected. Used by all subsequent Compose invocations in the script.
Error message (on failure) stderr output If neither Compose variant is found, the message "ERROR: Neither 'docker compose' nor 'docker-compose' is installed or available in PATH." is written to stderr.
Exit code Integer Returns 0 on success (Compose found). Exits with code 1 if no Compose variant is available.

Usage Examples

# Check Docker is installed
docker --version
# Expected: Docker version 24.x.x or later

# Check Docker Compose v2 (plugin)
docker compose version
# Expected: Docker Compose version v2.x.x

# Check Docker Compose v1 (standalone) -- fallback
docker-compose version
# Expected: docker-compose version 1.29.x

# Check Maven (only needed for local image builds)
mvn --version
# Expected: Apache Maven 3.x.x

# The get_docker_compose_cmd() function is called automatically
# at the top of run_spark_hudi.sh:
./run_spark_hudi.sh start
# If Compose is missing, you will see:
# ERROR: Neither 'docker compose' nor 'docker-compose' is installed or available in PATH.

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment