Overview
While Miku Miku Beam doesn’t include a pre-built Dockerfile in the repository, it’s designed to be Docker-ready and can be easily containerized for deployment. This guide will walk you through creating and deploying MMB in a Docker container.
Creating a Dockerfile
Multi-stage Dockerfile
Create a Dockerfile in the project root with the following content:
# Build stage for web client
FROM node:18-alpine AS web-builder
WORKDIR /app/web-client
COPY web-client/package*.json ./
RUN npm install --no-audit --no-fund
COPY web-client/ ./
RUN npm run build
# Build stage for Go binaries
FROM golang:1.21-alpine AS go-builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN mkdir -p bin/web-client
COPY --from=web-builder /app/web-client/dist/public/* bin/web-client/
RUN go build -o bin/mmb-server ./cmd/mmb-server
RUN go build -o bin/mmb-cli ./cmd/mmb-cli
# Final runtime stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /app
# Copy binaries and web assets
COPY --from=go-builder /app/bin/mmb-server /app/mmb-server
COPY --from=go-builder /app/bin/mmb-cli /app/mmb-cli
COPY --from=go-builder /app/bin/web-client /app/bin/web-client
# Create data directory for configuration
RUN mkdir -p /app/data
# Expose the server port
EXPOSE 3000
# Run the server
CMD [ "/app/mmb-server" ]
Docker Compose Setup
Create a docker-compose.yml file for easier deployment:
version : '3.8'
services :
mmb-server :
build :
context : .
dockerfile : Dockerfile
container_name : miku-miku-beam
ports :
- "3000:3000"
volumes :
- ./data:/app/data
- ./config.toml:/app/config.toml:ro
environment :
- LOG_FORMAT=json
- ALLOW_NO_PROXY=false
restart : unless-stopped
networks :
- mmb-network
networks :
mmb-network :
driver : bridge
Building the Image
Build with Docker
Build the Docker image directly: docker build -t miku-miku-beam:latest .
Or build with Docker Compose
Build using Docker Compose:
Configuration Files
Before running the container, prepare the required configuration files:
Create proxies.txt
Add your proxy list (one per line): cat > data/proxies.txt << EOF
http://proxy1.example.com:8080
http://user:[email protected] :3128
socks5://proxy3.example.com:1080
EOF
Proxy format supports:
protocol://user:password@host:port (with authentication)
protocol://host:port
host:port (defaults to HTTP)
host (defaults to port 8080)
Create uas.txt
Add user agent strings (one per line): cat > data/uas.txt << EOF
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36
EOF
Create config.toml (optional)
Override default configuration: proxies_file = "data/proxies.txt"
user_agents_file = "data/uas.txt"
server_port = 3000
allowed_origin = "http://localhost:5173"
Running the Container
Using Docker Run
docker run -d \
--name miku-miku-beam \
-p 3000:3000 \
-v $( pwd ) /data:/app/data \
-e LOG_FORMAT=json \
-e ALLOW_NO_PROXY= false \
--restart unless-stopped \
miku-miku-beam:latest
Using Docker Compose
# Start the service
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the service
docker-compose down
Environment Variables
Log output format. Set to json for structured logging in production
Allow running attacks without proxies. Set to true to enable
Volume Mounts
Host Path Container Path Purpose ./data/app/dataProxies and user agents storage ./config.toml/app/config.tomlConfiguration file (optional)
Port Mappings
Container Port Protocol Purpose 3000 HTTP Web UI and API
Health Checks
Add a health check to your Dockerfile:
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/attacks || exit 1
Or in docker-compose.yml:
services :
mmb-server :
# ... other config
healthcheck :
test : [ "CMD" , "wget" , "--no-verbose" , "--tries=1" , "--spider" , "http://localhost:3000/attacks" ]
interval : 30s
timeout : 3s
retries : 3
start_period : 5s
Docker CLI Access
You can also run attacks using the CLI tool inside the container:
# Execute CLI commands
docker exec -it miku-miku-beam /app/mmb-cli attack http_flood http://example.com
# With custom parameters
docker exec -it miku-miku-beam /app/mmb-cli attack http_bypass http://example.com \
--duration 120 \
--delay 100 \
--packet-size 1024 \
--threads 8 \
--verbose
Production Optimization
Optimized Dockerfile
Production Docker Compose
# Use specific versions for reproducibility
FROM node:18.19-alpine AS web-builder
WORKDIR /app/web-client
COPY web-client/package*.json ./
RUN npm ci --only=production --no-audit --no-fund
COPY web-client/ ./
RUN npm run build
FROM golang:1.21-alpine AS go-builder
RUN apk add --no-cache git ca-certificates
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN mkdir -p bin/web-client
COPY --from=web-builder /app/web-client/dist/public/* bin/web-client/
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags= '-w -s' \
-o bin/mmb-server ./cmd/mmb-server
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags= '-w -s' \
-o bin/mmb-cli ./cmd/mmb-cli
FROM alpine:latest
RUN apk --no-cache add ca-certificates wget
WORKDIR /app
COPY --from=go-builder /app/bin/mmb-server /app/mmb-server
COPY --from=go-builder /app/bin/mmb-cli /app/mmb-cli
COPY --from=go-builder /app/bin/web-client /app/bin/web-client
RUN mkdir -p /app/data && \
addgroup -g 1000 mmb && \
adduser -D -u 1000 -G mmb mmb && \
chown -R mmb:mmb /app
USER mmb
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/attacks || exit 1
CMD [ "/app/mmb-server" ]
Troubleshooting
Container starts but web UI is not accessible
Check if the web client was built correctly: docker exec miku-miku-beam ls -la /app/bin/web-client
If empty, rebuild the image ensuring the web-client build stage completes successfully.
No proxies available error
Ensure the data volume is mounted correctly and contains proxies.txt: docker exec miku-miku-beam cat /app/data/proxies.txt
Or run with ALLOW_NO_PROXY=true to disable proxy requirement.
If using the non-root user setup, ensure proper permissions:
Next Steps
Production Deployment Learn how to deploy MMB in production environments
Configuration Configure server settings and parameters