Installing HBase with Docker for Local Practice
Installing HBase with Docker
Let’s install HBase in a Docker environment using the Docker image below.
- HBase Docker image to install
Downloading HBase Docker run commands
Download, or clone, the HBase Docker run commands from the GitHub repository below.
git clone git@github.com:dajobe/hbase-docker.git
Running HBase Docker
With Docker running, execute the following command as-is.
./start-hbase.sh
It is recommended to use the start-hbase.sh script, which starts the container, inspects it to determine all local API ports and web UI ports, and suggests editing /etc/hosts to add an alias for the container IP if it does not already exist.
It is recommended to use the start-hbase.sh script, which starts the container, determines all local API ports and web UI ports, and suggests editing /etc/hosts to add an alias for the container IP if it does not already exist.
% ./start-hbase.sh
start-hbase.sh: Starting HBase container
Error: No such container: hbase-docker
Unable to find image 'dajobe/hbase:latest' locally
latest: Pulling from dajobe/hbase
6cf436f81810: Pulling fs layer
... omitted ...
159beed970fa: Pull complete
Digest: sha256:daa36a6d90b118ced866b6c76fcd918e7da73302b0e4971f506f0f61f645a9fe
Status: Downloaded newer image for dajobe/hbase:latest
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
start-hbase.sh: Container has ID 3804d552250334cc850189e076b77cb0d3066850cef332bec7a125dc29228361
./start-hbase.sh: line 32: python: command not found
Here, the container ID is 3804d552250334cc850189e076b77cb0d3066850cef332bec7a125dc29228361. Record it because it is needed when running the shell.
When you run the command above, data is created in the current path where it was run, ports are opened, and HBase should run.
Manual run method
docker run --name=hbase-docker \
-h hbase-docker \
-p 9095:9095 \
-p 8085:8085 \
-p 16010:16010 \
-v $PWD/data:/data \
-d dajobe/hbase
Running the HBase Shell
Next, let’s run the shell command that can connect to HBase using the Docker image.
Put the container ID recorded above into $id and run it.
docker run --rm -it --link $id:hbase-docker dajobe/hbase hbase shell
On macOS Apple Silicon, such as M1 or M2, the following error may occur.
% docker run --rm -it --link 3804d552250334cc850189e076b77cb0d3066850cef332bec7a125dc29228361:hbase-docker dajobe/hbase hbase shell
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
In that case, delete the Docker container that is already running, add the --platform linux/amd64 option, and run it again.
% docker run --rm -it --platform linux/amd64 --link 3804d552250334cc850189e076b77cb0d3066850cef332bec7a125dc29228361:hbase-docker dajobe/hbase hbase shell
2023-06-16 09:38:17,680 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.1.2, r1dfc418f77801fbfb59a125756891b9100c1fc6d, Sun Dec 30 21:45:09 PST 2018
Took 0.0480 seconds
hbase(main):001:0>
The command to exit the shell is quit.
hbase(main):005:0> quit
How to use commands will be explained on the next page.