Longhorn Cloud-Native Storage
Lightweight distributed block storage for Kubernetes with snapshots and backups.
Overview
Longhorn is a cloud-native distributed block storage system designed specifically for Kubernetes environments, originally developed by Rancher Labs and now part of the CNCF landscape. The longhorn-manager serves as the orchestration engine that coordinates storage operations, handles volume lifecycle management, and maintains cluster-wide storage metadata across distributed nodes. This lightweight yet powerful storage solution addresses the critical challenge of providing persistent, replicated storage for containerized applications without requiring expensive SAN infrastructure or vendor lock-in.
This configuration combines Longhorn's core components with MinIO to create a comprehensive storage ecosystem for containerized environments. The longhorn-manager orchestrates storage operations while longhorn-engine handles the actual block device operations and data replication across nodes. The longhorn-ui provides a web interface for managing volumes, snapshots, and backups, while MinIO serves as the S3-compatible backend for storing Longhorn backups and snapshots outside the cluster.
This stack is ideal for platform engineers, DevOps teams, and organizations building Kubernetes infrastructure who need enterprise-grade storage features like snapshots, cross-cluster replication, and disaster recovery without the complexity of traditional SAN solutions. The combination provides both local high-performance block storage and remote backup capabilities, making it particularly valuable for stateful applications requiring data durability guarantees.
Key Features
- Distributed block storage with configurable replica counts across multiple nodes for high availability
- Incremental snapshot functionality with space-efficient storage and instant recovery capabilities
- Cross-cluster backup and restore using S3-compatible storage backends like the integrated MinIO
- Volume expansion and migration without downtime for running applications
- Built-in data locality optimization to reduce network overhead during read operations
- Disaster recovery with scheduled backup policies and cross-region replication support
- Real-time volume health monitoring with automatic replica rebuilding on node failures
- CSI driver integration providing native Kubernetes StorageClass and PVC support
Common Use Cases
- 1Kubernetes clusters requiring persistent storage for databases like PostgreSQL, MySQL, or MongoDB
- 2CI/CD environments needing reliable storage for build artifacts and test data with snapshot rollback capabilities
- 3Multi-tenant SaaS platforms requiring isolated storage with backup and disaster recovery per tenant
- 4Edge computing deployments where traditional SAN storage is impractical but data persistence is critical
- 5Development and staging environments needing production-like storage with easy snapshot-based environment cloning
- 6Hybrid cloud setups requiring consistent storage behavior between on-premises and cloud Kubernetes clusters
- 7Backup consolidation for multiple applications using MinIO as a centralized S3-compatible storage backend
Prerequisites
- Minimum 4GB RAM available with at least 2GB allocated to longhorn-manager for metadata operations
- Docker host with privileged container support and access to /dev for block device operations
- Ports 8000, 9000, 9001, and 9500 available for Longhorn UI, MinIO API, MinIO console, and manager API respectively
- Understanding of block storage concepts, CSI drivers, and Kubernetes storage primitives
- Basic knowledge of S3 API operations for configuring backup destinations and retention policies
- Sufficient disk space with separate volumes recommended for Longhorn data and MinIO storage backends
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 longhorn-manager: 3 image: longhornio/longhorn-manager:latest4 privileged: true5 ports: 6 - "9500:9500"7 environment: 8 - LONGHORN_MANAGER_IP=longhorn-manager9 volumes: 10 - /var/run/docker.sock:/var/run/docker.sock11 - longhorn_data:/var/lib/longhorn12 - /dev:/dev13 networks: 14 - longhorn-net15 restart: unless-stopped1617 longhorn-ui: 18 image: longhornio/longhorn-ui:latest19 ports: 20 - "8000:8000"21 environment: 22 - LONGHORN_MANAGER_IP=http://longhorn-manager:950023 depends_on: 24 - longhorn-manager25 networks: 26 - longhorn-net27 restart: unless-stopped2829 longhorn-engine: 30 image: longhornio/longhorn-engine:latest31 privileged: true32 volumes: 33 - /var/run/docker.sock:/var/run/docker.sock34 - longhorn_engine:/engine35 networks: 36 - longhorn-net37 restart: unless-stopped3839 minio: 40 image: minio/minio:latest41 ports: 42 - "9000:9000"43 - "9001:9001"44 environment: 45 MINIO_ROOT_USER: ${MINIO_ACCESS_KEY}46 MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY}47 volumes: 48 - minio_data:/data49 command: server /data --console-address ":9001"50 networks: 51 - longhorn-net52 restart: unless-stopped5354volumes: 55 longhorn_data: 56 longhorn_engine: 57 minio_data: 5859networks: 60 longhorn-net: 61 driver: bridge.env Template
.env
1# MinIO Backup Target2MINIO_ACCESS_KEY=minioadmin3MINIO_SECRET_KEY=secure_minio_password45# Longhorn Settings6LONGHORN_DEFAULT_DATA_PATH=/var/lib/longhornUsage Notes
- 1Longhorn UI at http://localhost:8000
- 2Manager API at http://localhost:9500
- 3MinIO console at http://localhost:9001
- 4Best used with Kubernetes, standalone mode limited
Individual Services(4 services)
Copy individual services to mix and match with your existing compose files.
longhorn-manager
longhorn-manager:
image: longhornio/longhorn-manager:latest
privileged: true
ports:
- "9500:9500"
environment:
- LONGHORN_MANAGER_IP=longhorn-manager
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- longhorn_data:/var/lib/longhorn
- /dev:/dev
networks:
- longhorn-net
restart: unless-stopped
longhorn-ui
longhorn-ui:
image: longhornio/longhorn-ui:latest
ports:
- "8000:8000"
environment:
- LONGHORN_MANAGER_IP=http://longhorn-manager:9500
depends_on:
- longhorn-manager
networks:
- longhorn-net
restart: unless-stopped
longhorn-engine
longhorn-engine:
image: longhornio/longhorn-engine:latest
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- longhorn_engine:/engine
networks:
- longhorn-net
restart: unless-stopped
minio
minio:
image: minio/minio:latest
ports:
- "9000:9000"
- "9001:9001"
environment:
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY}
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY}
volumes:
- minio_data:/data
command: server /data --console-address ":9001"
networks:
- longhorn-net
restart: unless-stopped
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 longhorn-manager:5 image: longhornio/longhorn-manager:latest6 privileged: true7 ports:8 - "9500:9500"9 environment:10 - LONGHORN_MANAGER_IP=longhorn-manager11 volumes:12 - /var/run/docker.sock:/var/run/docker.sock13 - longhorn_data:/var/lib/longhorn14 - /dev:/dev15 networks:16 - longhorn-net17 restart: unless-stopped1819 longhorn-ui:20 image: longhornio/longhorn-ui:latest21 ports:22 - "8000:8000"23 environment:24 - LONGHORN_MANAGER_IP=http://longhorn-manager:950025 depends_on:26 - longhorn-manager27 networks:28 - longhorn-net29 restart: unless-stopped3031 longhorn-engine:32 image: longhornio/longhorn-engine:latest33 privileged: true34 volumes:35 - /var/run/docker.sock:/var/run/docker.sock36 - longhorn_engine:/engine37 networks:38 - longhorn-net39 restart: unless-stopped4041 minio:42 image: minio/minio:latest43 ports:44 - "9000:9000"45 - "9001:9001"46 environment:47 MINIO_ROOT_USER: ${MINIO_ACCESS_KEY}48 MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY}49 volumes:50 - minio_data:/data51 command: server /data --console-address ":9001"52 networks:53 - longhorn-net54 restart: unless-stopped5556volumes:57 longhorn_data:58 longhorn_engine:59 minio_data:6061networks:62 longhorn-net:63 driver: bridge64EOF6566# 2. Create the .env file67cat > .env << 'EOF'68# MinIO Backup Target69MINIO_ACCESS_KEY=minioadmin70MINIO_SECRET_KEY=secure_minio_password7172# Longhorn Settings73LONGHORN_DEFAULT_DATA_PATH=/var/lib/longhorn74EOF7576# 3. Start the services77docker compose up -d7879# 4. View logs80docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/longhorn-storage/run | bashTroubleshooting
- longhorn-manager fails with 'permission denied' accessing /dev: Ensure the container runs in privileged mode and the Docker daemon has access to block devices
- Longhorn UI shows 'Manager API unreachable': Verify longhorn-manager container is running and port 9500 is accessible within the Docker network
- Volume attachment fails with 'no healthy replicas': Check that longhorn-engine containers are running and have sufficient disk space in mounted volumes
- MinIO backup configuration fails with 'AccessDenied': Verify MINIO_ACCESS_KEY and MINIO_SECRET_KEY environment variables are properly set and match Longhorn backup target credentials
- Snapshot creation fails with 'insufficient space': Monitor the longhorn_data volume usage and ensure adequate free space for snapshot metadata and differentials
- Engine process crashes with 'device busy': Stop any processes accessing Longhorn volumes and ensure proper volume unmounting before container restarts
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
longhorn-managerlonghorn-uilonghorn-engineminio
Tags
#longhorn#block-storage#kubernetes#snapshots#backups
Category
Storage & BackupAd Space
Shortcuts: C CopyF FavoriteD Download