A simple cryptocurrency mining simulator for learning Kubernetes concepts.
DockerCoins is an educational application that simulates cryptocurrency mining. It consists of 5 microservices that work together:
- rng - Generates random bytes (Python/Flask)
- hasher - Computes SHA256 hashes (Ruby/Sinatra)
- worker - Coordinates the mining process (Python)
- webui - Shows mining statistics (Node.js/Express)
- redis - Stores data (standard Redis image)
┌──────────┐
│ webui │ ◄── You view this in browser
└────┬─────┘
│ reads
▼
┌────────┐ bytes ┌──────────┐ hash ┌──────────┐
│ rng │ ◄─────── │ worker │ ──────► │ hasher │
└────────┘ └────┬─────┘ └──────────┘
│ writes
▼
┌──────────┐
│ redis │
└──────────┘
See full walkthrough in [LAB.md]
Edit webui/files/index.html and replace YOUR_NAME with your actual name:
<h1>DockerCoin Miner - YOUR_NAME</h1>Change to:
<h1>DockerCoin Miner - John Smith</h1>Set your Docker Hub username:
export DOCKER_USER=your_dockerhub_usernameBuild and push all images:
# Build all images
docker build -t $DOCKER_USER/rng:v1 ./rng
docker build -t $DOCKER_USER/hasher:v1 ./hasher
docker build -t $DOCKER_USER/worker:v1 ./worker
docker build -t $DOCKER_USER/webui:v1 ./webui
# Push to Docker Hub
docker push $DOCKER_USER/rng:v1
docker push $DOCKER_USER/hasher:v1
docker push $DOCKER_USER/worker:v1
docker push $DOCKER_USER/webui:v1kubectl create deployment redis --image=redis
kubectl create deployment rng --image=$DOCKER_USER/rng:v1
kubectl create deployment hasher --image=$DOCKER_USER/hasher:v1
kubectl create deployment worker --image=$DOCKER_USER/worker:v1
kubectl create deployment webui --image=$DOCKER_USER/webui:v1Verify pods are running:
kubectl get podsWait until all pods show Running status.
kubectl expose deployment redis --port 6379
kubectl expose deployment rng --port 80
kubectl expose deployment hasher --port 80
kubectl expose deployment webui --type=NodePort --port=80minikube service webuiYour app will be automatically opened in a web browser:
When you want to start fresh or clean up after the lab:
minikube deleteThis stops and removes the entire Kubernetes cluster.
First, set your Docker Hub username (replace with your actual username):
export DOCKER_USER=your_dockerhub_usernameThen remove the images:
docker rmi $DOCKER_USER/rng:v1
docker rmi $DOCKER_USER/hasher:v1
docker rmi $DOCKER_USER/worker:v1
docker rmi $DOCKER_USER/webui:v1If you get "image is being used" errors, force removal with -f flag:
docker rmi -f $DOCKER_USER/rng:v1
docker rmi -f $DOCKER_USER/hasher:v1
docker rmi -f $DOCKER_USER/worker:v1
docker rmi -f $DOCKER_USER/webui:v1- Go to Docker Hub
- Log in to your account
- Click Repositories
- For each repository (rng, hasher, worker, webui):
- Click the repository name
- Click Settings tab
- Scroll down → Delete repository
- Type the repository name to confirm
This is a modernized version of the original DockerCoins demo by Jérôme Petazzoni. Used for educational purposes.