Run HBase in Docker with one command. Perfect for:
Prerequisites:
Get HBase running in 3 commands:
# 1. Go to the docker directory cd dev-support/hbase_docker # 2. Build HBase (one command, ~15 minutes) ./build-hbase.sh --tag master # 3. Start HBase shell docker run --platform linux/amd64 -it --rm hbase_local
Try it out:
# Inside HBase shell: create 'test', 'cf' put 'test', 'row1', 'cf:a', 'value1' scan 'test' exit
That's it! No installation, no configuration needed. ๐
Apple Silicon (M1/M2/M3): The build script automatically selects the right Dockerfile for your chip. For
docker runcommands, always pass--platform linux/amd64โ the image is x86_64 running under Rosetta.
The script supports three modes:
./build-hbase.sh --tag master ./build-hbase.sh --tag branch-2.4 ./build-hbase.sh --tag rel/2.6.7
Use when: Learning HBase, testing specific versions
./build-hbase.sh --tarball ~/Downloads/hbase-2.6.7-src.tar.gz
Use when: Verifying release candidates, testing official releases
# From any HBase repository ./build-hbase.sh --source ~/Code/hbase # From current repository ./build-hbase.sh --source .
Use when: Testing your code changes, debugging, active development
Perfect for HBase developers working on patches or new features.
After building, you have several options:
docker run --platform linux/amd64 -it --rm hbase_local
This starts HBase in standalone mode and gives you the HBase shell.
docker run --platform linux/amd64 -it --rm hbase_local bash
Gives you a bash prompt to explore the container.
docker run --platform linux/amd64 -it --rm hbase_local bash -c ' cd /root/hbase && mvn clean install '
The container has the full source code and Maven ready to use.
# Build once ./build-hbase.sh --tag master # Start HBase whenever you want to experiment docker run --platform linux/amd64 -it --rm hbase_local # Play around with HBase commands create 'users', 'info', 'contact' put 'users', 'john', 'info:name', 'John Doe' get 'users', 'john' scan 'users'
# Download RC tarball from Apache wget https://dist.apache.org/repos/dist/dev/hbase/hbase-2.6.7RC0/hbase-2.6.7-src.tar.gz # Build from it cd dev-support/hbase_docker ./build-hbase.sh --tarball hbase-2.6.7-src.tar.gz hbase_267_rc0 # Test it works docker run --platform linux/amd64 -it --rm hbase_267_rc0 # Run tests (optional) docker run --platform linux/amd64 -it --rm hbase_267_rc0 bash -c ' cd /root/hbase && mvn test '
# 1. Make changes to HBase code vim hbase-server/src/main/java/org/apache/hadoop/hbase/MyClass.java # 2. Build Docker image with your changes (includes uncommitted changes!) cd dev-support/hbase_docker ./build-hbase.sh --source . my_feature # 3. Test your changes in HBase shell docker run --platform linux/amd64 -it --rm my_feature # 4. Or run unit tests docker run --platform linux/amd64 -it --rm my_feature bash -c ' cd /root/hbase && mvn test -Dtest=MyTest ' # 5. Run full test suite docker run --platform linux/amd64 -it --rm my_feature bash -c ' cd /root/hbase && mvn clean install '
Note: This builds from your working directory, including uncommitted changes. Great for testing patches before committing!
The Docker image includes Maven and all dependencies. You can run any Maven command:
# Start bash in the container docker run --platform linux/amd64 -it --rm hbase_local bash # Inside container: cd /root/hbase # Run full build with tests mvn clean install # Run tests only mvn test # Skip tests mvn clean install -DskipTests # Run integration tests mvn verify
Important: Files are copied into the image. Changes inside the container don't affect your local files.
If you're actively developing and need changes to persist to your local files:
# 1. Build a base image once (use any stable branch) ./build-hbase.sh --tag master hbase_dev # 2. Run with your local code mounted cd /path/to/hbase docker run --platform linux/amd64 \ -v $(pwd):/workspace \ -w /workspace \ -it --rm hbase_dev bash # 3. Inside container - changes persist to your local files! mvn clean install # Build from your local code mvn spotless:apply # Format your local files mvn test # Run tests exit # 4. Changes are now in your local files git diff # See the changes git add .
Why use this?
When not to use:
--source mode instead (simpler)โ ERROR: Docker daemon is not running
Fix: Start Docker Desktop app
โ ๏ธ WARNING: Low disk space
Fix: Clean up old Docker images
docker image prune -a
This is normal on Apple Silicon โ Docker uses Rosetta 2 emulation to run the x86_64 image.
Note: Apple is deprecating Rosetta. Once removed, builds will still work via QEMU emulation but will be slower. A native arm64 image is planned for a future release.
Make sure the script is executable:
chmod +x build-hbase.sh
./build-hbase.sh --help
If you prefer raw Docker commands instead of the script:
docker build --platform linux/amd64 -t hbase . docker build --platform linux/amd64 --build-arg BRANCH_OR_TAG=branch-2.4 -t hbase .
cp /path/to/hbase-src.tar.gz hbase-src.tar.gz docker build --platform linux/amd64 --build-arg INPUT_MODE=tarball -t hbase .
# Use the source directory as the build context directly docker build --platform linux/amd64 \ --build-arg INPUT_MODE=source-dir \ -f /path/to/hbase_docker/Dockerfile \ -t hbase \ /path/to/hbase
The Dockerfile supports three input modes via INPUT_MODE:
tag (default) - Clone from GitHubtarball - Extract from local hbase-src.tar.gzsource-dir - Copy from local hbase/ directoryAfter build:
/root/hbase//root/hbase-bin//opt/maven/.dockerignore controls what gets copied:
hbase-src.tar.gz or hbase/ directory--tag mode (clone from GitHub)The build-hbase.sh script checks these automatically and shows helpful errors.
Add a third argument to customize the image name:
./build-hbase.sh --tag branch-2.4 my_custom_name ./build-hbase.sh --tarball hbase.tar.gz hbase_rc_test ./build-hbase.sh --source ~/Code/hbase hbase_dev
Then run with your custom name:
docker run --platform linux/amd64 -it --rm my_custom_name
The build-hbase.sh script automates setup:
Logs are saved to /tmp/hbase-docker-build.log
You can skip the script and use raw Docker commands if you prefer.
# Build commands ./build-hbase.sh --tag branch-2.4 # From GitHub ./build-hbase.sh --tarball hbase.tar.gz # From tarball ./build-hbase.sh --source ~/Code/hbase # From local source # Run commands docker run --platform linux/amd64 -it --rm hbase_local # HBase shell docker run --platform linux/amd64 -it --rm hbase_local bash # Bash shell # Maven in container cd /root/hbase && mvn clean install # Full build with tests cd /root/hbase && mvn test # Tests only # Help ./build-hbase.sh --help # Show usage docker images | grep hbase # List images