This Docker image provides a local MiniDFSCluster environment to simplify testing HDFS-based applications such as Apache Spark.
- NameNode with fixed ports for both RPC and Web UI.
- Configurable number of DataNodes (default: 1, max: 9).
- Automatic creation of
/tmpand/userdirectories in HDFS. - Verified on Ubuntu, CentOS, Windows, and macOS.
The Docker image is available on GitHub Packages:
ghcr.io/avs-alatau/minidfscluster
docker pull ghcr.io/avs-alatau/minidfscluster:latestdocker run -d --name hdfs-minicluster --network=host \
-e NUM_DATANODES=3 ghcr.io/avs-alatau/minidfscluster:latestdocker run -d --name hdfs-minicluster -p 35200:35200 -p 35100:35100 -p 30000-30030:30000-30030 -e NUM_DATANODES=3 ghcr.io/avs-alatau/minidfscluster:latest- The
NUM_DATANODESenvironment variable is optional (default: 1). - Maximum allowed
NUM_DATANODES: 9.
| Service | Port |
|---|---|
| NameNode RPC | 35200 |
| NameNode Web UI | 35100 |
| DataNode RPC | 30000-30030 |
| DataNode Transfer | 30000-30030 |
| DataNode HTTP | 30000-30030 |
After starting the container, wait for about 30 seconds, then check the logs:
docker logs hdfs-miniclusterThis will display connection details and available ports.
Use the full HDFS path for operations:
hdfs dfs -ls hdfs://localhost:35200/Upon startup, the following directories are created:
/tmp/user
You can run spark-shell and connect to HDFS:
/opt/spark-3.5.1/bin/spark-shell --master local[*] \
--conf spark.hadoop.fs.defaultFS=hdfs://localhost:35200For issues, improvements, or contributions, please visit the GitHub repository.
Happy Testing!