docker.recipes

LiveKit

intermediate

Real-time video, audio and data SDK.

Overview

LiveKit is an open-source, production-grade platform that provides real-time video, audio, and data communication capabilities through WebRTC technology. Originally developed to democratize access to video conferencing infrastructure, LiveKit serves as a compelling alternative to proprietary solutions like Twilio Video, Zoom SDK, or Agora, offering developers complete control over their real-time communication stack without vendor lock-in or per-minute pricing models. This Docker deployment creates a self-hosted LiveKit server that handles WebRTC signaling, media routing, and room management through a single containerized service. The LiveKit server acts as a Selective Forwarding Unit (SFU) that efficiently distributes media streams between participants while providing APIs for room creation, participant management, and real-time data channels, making it possible to build sophisticated video applications with minimal infrastructure overhead. This configuration is ideal for startups building video-first applications, enterprises requiring on-premises communication solutions, or developers creating custom conferencing tools who need predictable costs and full data sovereignty. The setup provides production-ready video infrastructure that can scale from small team meetings to large-scale broadcast scenarios with thousands of concurrent participants.

Key Features

  • WebRTC-based Selective Forwarding Unit (SFU) for efficient multi-participant video distribution
  • Real-time room management with dynamic participant joining and track subscription controls
  • Adaptive bitrate streaming with automatic quality adjustment based on network conditions
  • Server-side recording and egress capabilities for archiving sessions or streaming to external platforms
  • Built-in data channels for real-time messaging and custom signaling alongside media streams
  • Multi-track audio and video support with screen sharing and device switching capabilities
  • JWT-based authentication with granular permissions for room access and publishing rights
  • Load balancing support for horizontal scaling across multiple server instances

Common Use Cases

  • 1Building custom video conferencing applications for remote teams and distributed organizations
  • 2Creating online education platforms with interactive classrooms and student engagement tools
  • 3Developing telehealth solutions requiring HIPAA-compliant video consultations
  • 4Implementing live streaming platforms with audience interaction and real-time chat
  • 5Building collaborative design tools with screen sharing and real-time communication
  • 6Creating gaming platforms that require voice chat and real-time coordination features
  • 7Developing customer support systems with video calling and screen sharing capabilities

Prerequisites

  • Minimum 2GB RAM and 2 CPU cores for handling moderate concurrent sessions
  • Network environment with properly configured firewall allowing UDP traffic on ports 7881-7882
  • Valid SSL certificate and domain name for production WebRTC connectivity
  • Basic understanding of WebRTC concepts and JWT token generation for authentication
  • Client-side SDK integration knowledge for your target platforms (React, Swift, Android, etc.)
  • Understanding of media server scaling concepts for high-availability deployments

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 livekit:
3 image: livekit/livekit-server:latest
4 container_name: livekit
5 restart: unless-stopped
6 command: --config /etc/livekit.yaml
7 environment:
8 LIVEKIT_KEYS: "${API_KEY}: ${API_SECRET}"
9 volumes:
10 - ./livekit.yaml:/etc/livekit.yaml
11 ports:
12 - "7880:7880"
13 - "7881:7881/udp"
14 - "7882:7882/udp"

.env Template

.env
1API_KEY=devkey
2API_SECRET=secret

Usage Notes

  1. 1Docs: https://docs.livekit.io/
  2. 2API/WebSocket on port 7880, UDP media on 7881-7882
  3. 3Create livekit.yaml: port: 7880, keys: {api-key: secret}
  4. 4SDKs for React, JS, Swift, Android, Flutter, Unity
  5. 5Features: rooms, tracks, data channels, recording, egress
  6. 6Open-source Zoom/Twilio alternative for video conferencing

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 livekit:
5 image: livekit/livekit-server:latest
6 container_name: livekit
7 restart: unless-stopped
8 command: --config /etc/livekit.yaml
9 environment:
10 LIVEKIT_KEYS: "${API_KEY}: ${API_SECRET}"
11 volumes:
12 - ./livekit.yaml:/etc/livekit.yaml
13 ports:
14 - "7880:7880"
15 - "7881:7881/udp"
16 - "7882:7882/udp"
17EOF
18
19# 2. Create the .env file
20cat > .env << 'EOF'
21API_KEY=devkey
22API_SECRET=secret
23EOF
24
25# 3. Start the services
26docker compose up -d
27
28# 4. View logs
29docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/livekit/run | bash

Troubleshooting

  • WebRTC connection failures in production: Ensure proper TURN server configuration and SSL certificates are properly configured for secure contexts
  • Participants cannot see or hear each other: Verify UDP ports 7881-7882 are open and accessible, check firewall rules blocking media traffic
  • High CPU usage during video calls: Implement proper video resolution limits and enable hardware acceleration if available on the host system
  • JWT authentication errors when joining rooms: Verify API_KEY and API_SECRET environment variables match your token generation code
  • Audio echo or feedback issues: Configure proper echo cancellation settings in client SDKs and ensure participants use headphones
  • Container fails to start with config errors: Ensure livekit.yaml file exists with proper port and keys configuration matching environment variables

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

Ad Space