docker.recipes

PeerTube Video Platform

advanced

PeerTube federated video hosting platform with ActivityPub support.

Overview

PeerTube is a decentralized video hosting platform that emerged as an open-source alternative to centralized services like YouTube. Built by Framasoft and launched in 2018, PeerTube leverages ActivityPub protocol for federation and WebTorrent technology for peer-to-peer video distribution. This approach reduces server bandwidth costs while creating a network of interconnected video platforms that can share content and audiences across instances. PostgreSQL serves as PeerTube's primary database, handling complex video metadata, user accounts, federation data, and comment systems with the reliability and ACID compliance required for content management platforms. Redis provides high-speed caching for video thumbnails, user sessions, and federation message queues, while also managing real-time features like live streaming coordination and background job processing. Content creators, educational institutions, and organizations seeking video hosting independence will find this stack particularly valuable for building sustainable video communities without relying on corporate platforms. The federation capabilities mean your instance can connect with thousands of other PeerTube servers worldwide, dramatically expanding your potential audience while maintaining full control over your content and community policies.

Key Features

  • ActivityPub federation allowing content sharing and discovery across PeerTube instances worldwide
  • WebTorrent peer-to-peer video streaming reducing server bandwidth costs through viewer participation
  • RTMP live streaming support on port 1935 with Redis-coordinated real-time chat and viewer management
  • PostgreSQL-powered advanced video categorization with tags, channels, playlists, and full-text search
  • Redis-cached video transcoding queue management for multiple resolution and format processing
  • Federated comment system allowing users from other ActivityPub platforms like Mastodon to interact
  • Built-in video statistics and analytics stored in PostgreSQL with Redis performance optimization
  • Multi-language subtitle support with PostgreSQL storage and Redis caching for fast retrieval

Common Use Cases

  • 1Educational institutions hosting course videos with controlled access and student interaction features
  • 2Independent content creators building audiences across federated PeerTube networks
  • 3Organizations requiring GDPR-compliant video hosting with full data control and European server locations
  • 4Community groups sharing event recordings and live streaming local meetings or conferences
  • 5Businesses hosting product demonstrations and training videos without YouTube's advertising and algorithm constraints
  • 6News organizations publishing video content with federation reach while maintaining editorial independence
  • 7Gaming communities streaming gameplay and tournaments with integrated chat and community features

Prerequisites

  • Minimum 4GB RAM (2GB for PostgreSQL, 1GB for PeerTube transcoding, 512MB for Redis caching)
  • Docker host with ports 9000, 1935, 80, and 443 accessible for web interface and RTMP streaming
  • Valid domain name and SSL certificate for PEERTUBE_HOSTNAME federation requirements
  • Understanding of ActivityPub federation concepts and PeerTube instance administration
  • Storage planning for video files as PeerTube data volume will grow significantly with uploads
  • SMTP server configuration knowledge for user registration and notification emails

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 peertube:
3 image: chocobozzz/peertube:production-bookworm
4 container_name: peertube
5 environment:
6 - PEERTUBE_DB_USERNAME=${POSTGRES_USER}
7 - PEERTUBE_DB_PASSWORD=${POSTGRES_PASSWORD}
8 - PEERTUBE_DB_SSL=false
9 - PEERTUBE_DB_HOSTNAME=postgres
10 - PEERTUBE_REDIS_HOSTNAME=redis
11 - PEERTUBE_WEBSERVER_HOSTNAME=${PEERTUBE_HOSTNAME}
12 - PEERTUBE_WEBSERVER_PORT=443
13 - PEERTUBE_WEBSERVER_HTTPS=true
14 - PEERTUBE_TRUST_PROXY=["127.0.0.1", "loopback", "172.17.0.0/16"]
15 - PEERTUBE_SECRET=${PEERTUBE_SECRET}
16 - PEERTUBE_ADMIN_EMAIL=${PEERTUBE_ADMIN_EMAIL}
17 - PT_INITIAL_ROOT_PASSWORD=${PT_INITIAL_ROOT_PASSWORD}
18 volumes:
19 - peertube_data:/data
20 - peertube_config:/config
21 ports:
22 - "9000:9000"
23 - "1935:1935"
24 depends_on:
25 - postgres
26 - redis
27 networks:
28 - peertube-network
29
30 postgres:
31 image: postgres:16-alpine
32 container_name: peertube-db
33 environment:
34 - POSTGRES_USER=${POSTGRES_USER}
35 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
36 - POSTGRES_DB=peertube
37 volumes:
38 - postgres_data:/var/lib/postgresql/data
39 networks:
40 - peertube-network
41
42 redis:
43 image: redis:7-alpine
44 container_name: peertube-redis
45 volumes:
46 - redis_data:/data
47 networks:
48 - peertube-network
49
50volumes:
51 peertube_data:
52 peertube_config:
53 postgres_data:
54 redis_data:
55
56networks:
57 peertube-network:
58 driver: bridge

.env Template

.env
1# PeerTube
2POSTGRES_USER=peertube
3POSTGRES_PASSWORD=peertube_password
4PEERTUBE_HOSTNAME=peertube.example.com
5PEERTUBE_SECRET=your-peertube-secret
6PEERTUBE_ADMIN_EMAIL=admin@example.com
7PT_INITIAL_ROOT_PASSWORD=your_root_password

Usage Notes

  1. 1Web interface at http://localhost:9000
  2. 2Login as root with initial password
  3. 3Supports federation with other instances
  4. 4Live streaming via RTMP
  5. 5Configure hostname for production

Individual Services(3 services)

Copy individual services to mix and match with your existing compose files.

peertube
peertube:
  image: chocobozzz/peertube:production-bookworm
  container_name: peertube
  environment:
    - PEERTUBE_DB_USERNAME=${POSTGRES_USER}
    - PEERTUBE_DB_PASSWORD=${POSTGRES_PASSWORD}
    - PEERTUBE_DB_SSL=false
    - PEERTUBE_DB_HOSTNAME=postgres
    - PEERTUBE_REDIS_HOSTNAME=redis
    - PEERTUBE_WEBSERVER_HOSTNAME=${PEERTUBE_HOSTNAME}
    - PEERTUBE_WEBSERVER_PORT=443
    - PEERTUBE_WEBSERVER_HTTPS=true
    - PEERTUBE_TRUST_PROXY=["127.0.0.1", "loopback", "172.17.0.0/16"]
    - PEERTUBE_SECRET=${PEERTUBE_SECRET}
    - PEERTUBE_ADMIN_EMAIL=${PEERTUBE_ADMIN_EMAIL}
    - PT_INITIAL_ROOT_PASSWORD=${PT_INITIAL_ROOT_PASSWORD}
  volumes:
    - peertube_data:/data
    - peertube_config:/config
  ports:
    - "9000:9000"
    - "1935:1935"
  depends_on:
    - postgres
    - redis
  networks:
    - peertube-network
postgres
postgres:
  image: postgres:16-alpine
  container_name: peertube-db
  environment:
    - POSTGRES_USER=${POSTGRES_USER}
    - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    - POSTGRES_DB=peertube
  volumes:
    - postgres_data:/var/lib/postgresql/data
  networks:
    - peertube-network
redis
redis:
  image: redis:7-alpine
  container_name: peertube-redis
  volumes:
    - redis_data:/data
  networks:
    - peertube-network

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 peertube:
5 image: chocobozzz/peertube:production-bookworm
6 container_name: peertube
7 environment:
8 - PEERTUBE_DB_USERNAME=${POSTGRES_USER}
9 - PEERTUBE_DB_PASSWORD=${POSTGRES_PASSWORD}
10 - PEERTUBE_DB_SSL=false
11 - PEERTUBE_DB_HOSTNAME=postgres
12 - PEERTUBE_REDIS_HOSTNAME=redis
13 - PEERTUBE_WEBSERVER_HOSTNAME=${PEERTUBE_HOSTNAME}
14 - PEERTUBE_WEBSERVER_PORT=443
15 - PEERTUBE_WEBSERVER_HTTPS=true
16 - PEERTUBE_TRUST_PROXY=["127.0.0.1", "loopback", "172.17.0.0/16"]
17 - PEERTUBE_SECRET=${PEERTUBE_SECRET}
18 - PEERTUBE_ADMIN_EMAIL=${PEERTUBE_ADMIN_EMAIL}
19 - PT_INITIAL_ROOT_PASSWORD=${PT_INITIAL_ROOT_PASSWORD}
20 volumes:
21 - peertube_data:/data
22 - peertube_config:/config
23 ports:
24 - "9000:9000"
25 - "1935:1935"
26 depends_on:
27 - postgres
28 - redis
29 networks:
30 - peertube-network
31
32 postgres:
33 image: postgres:16-alpine
34 container_name: peertube-db
35 environment:
36 - POSTGRES_USER=${POSTGRES_USER}
37 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
38 - POSTGRES_DB=peertube
39 volumes:
40 - postgres_data:/var/lib/postgresql/data
41 networks:
42 - peertube-network
43
44 redis:
45 image: redis:7-alpine
46 container_name: peertube-redis
47 volumes:
48 - redis_data:/data
49 networks:
50 - peertube-network
51
52volumes:
53 peertube_data:
54 peertube_config:
55 postgres_data:
56 redis_data:
57
58networks:
59 peertube-network:
60 driver: bridge
61EOF
62
63# 2. Create the .env file
64cat > .env << 'EOF'
65# PeerTube
66POSTGRES_USER=peertube
67POSTGRES_PASSWORD=peertube_password
68PEERTUBE_HOSTNAME=peertube.example.com
69PEERTUBE_SECRET=your-peertube-secret
70PEERTUBE_ADMIN_EMAIL=admin@example.com
71PT_INITIAL_ROOT_PASSWORD=your_root_password
72EOF
73
74# 3. Start the services
75docker compose up -d
76
77# 4. View logs
78docker 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/peertube-video/run | bash

Troubleshooting

  • Federation not working with other instances: Verify PEERTUBE_WEBSERVER_HOSTNAME matches your actual domain and SSL certificate is valid
  • Video transcoding fails or hangs: Increase Docker memory limits and check PeerTube container logs for ffmpeg errors
  • Redis connection errors in PeerTube logs: Ensure redis container is fully started before PeerTube using healthchecks or init containers
  • PostgreSQL connection refused: Check that POSTGRES_USER and POSTGRES_PASSWORD environment variables match between postgres and peertube services
  • RTMP live streaming not working: Verify port 1935 is open in firewall and not blocked by hosting provider
  • High memory usage during video uploads: Configure Redis maxmemory settings and consider enabling PostgreSQL connection pooling

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