How to Install PeerTube on a VPS with Docker for Self-Hosted Video

The problem: your videos live on a platform that can change the rules

Long-form video is a heavy asset. Once uploaded to a big platform, you depend on its algorithm to be found, its policies to stay published, and its compression choices for playback quality. For creators with an archive of tutorials, class recordings, or internal documentation, that dependence gets more expensive every year — not because of subscription fees, but because control over your own archive keeps thinning out.

PeerTube answers from a different direction. It is a self-hosted video sharing platform that can federate over ActivityPub: your instance can stand entirely alone, or connect with other instances so videos can be discovered across servers. One thing to understand up front: PeerTube is not a YouTube clone you drop onto a tiny VPS and forget. It processes video, stores several resolution variants, and serves large files — and all three jobs demand real resources.

This guide installs PeerTube with the official Docker Compose setup from its repository, complete with PostgreSQL and Redis, using the Nginx web server already included in that Compose file. The domain you pick at the start is final — PeerTube does not support changing the web server host after the first install — so do not rush the domain step.

Prerequisites

  • A VPS with Docker and Docker Compose v2 (docker compose version should report a version above 2.x).
  • One domain already pointing at the VPS, for example video.example.com. This domain is final: after PeerTube first runs, changing it is not an officially supported operation and risks errors that are hard to predict.
  • Ports 80 and 443 open. Port 80 is used to issue the first Let’s Encrypt certificate, port 443 for viewers.
  • Generous disk space, ideally on SSD. Raw video plus transcoding output can run several times the size of the original file — size your disk from the total length of your archive, not from one test video.
  • An active admin email address, because it is used to generate the administrator account root on first start.

Realistic resource requirements, before you install anything

This section is worth reading twice, because it is where PeerTube installs most often disappoint. Running PeerTube’s web pages is light. What is heavy is transcoding: turning one uploaded video into several resolutions for playback on different connection speeds. Each transcoding job runs FFmpeg at high CPU load, takes time, and produces extra files on disk.

As a sensible starting point for a small instance — a few uploaders, a modest audience, occasional videos — choose a VPS with multiple CPU cores and comfortable RAM, not the cheapest plan available. If you plan to upload many videos per week or open registration to the public, size CPU and disk up from the start; adding resources halfway through is always more awkward than starting with enough. Live transcoding is heavier still: every live stream runs its own real-time FFmpeg process, so ten simultaneous streams mean ten heavy processes at once.

Storage has its own trap. PeerTube can serve video over HLS and over Web Video, and the two do not share the same file — enabling both can double storage for the same video. Decide up front which resolutions you genuinely need, and switch off the ones nobody watches.

Step 1: Download the official Compose file and .env

Create a working folder and move into it:

mkdir -p ~/peertube && cd ~/peertube

Download the Compose file and environment file from the official PeerTube repository:

curl https://raw.githubusercontent.com/chocobozzz/PeerTube/master/support/docker/production/docker-compose.yml > docker-compose.yml
curl https://raw.githubusercontent.com/Chocobozzz/PeerTube/master/support/docker/production/.env > .env

Before going further, open both files and read them. This Compose file already includes an Nginx web server, so you do not need a separate reverse proxy unless you specifically want one — in that case, the web server section in Compose can be commented out, as the official guide describes.

Step 2: Fill in .env with your domain, database, and secret

Open .env and replace these placeholders:

  • <MY POSTGRES USERNAME> — the PostgreSQL database username.
  • <MY POSTGRES PASSWORD> — the database password, generated with openssl rand -hex 32.
  • <MY DOMAIN> — your domain without https://, for example video.example.com.
  • <MY EMAIL ADDRESS> — the admin email for the root account.
  • <MY PEERTUBE SECRET> — a random secret, also generatable with openssl rand -hex 32.

These values drive the services in Compose: PostgreSQL stores instance data, Redis handles queues and caching, and PeerTube itself serves the app and video playback. Do not let placeholder values slip into a production server — an install left on example credentials is an open invitation to anyone who has read the same example file.

Step 3: Prepare the Nginx template and the first certificate

Create folders for the Nginx template and its logs, then download the official template:

mkdir -p docker-volume/nginx docker-volume/nginx-logs
curl https://raw.githubusercontent.com/Chocobozzz/PeerTube/master/support/nginx/peertube > docker-volume/nginx/peertube

The Nginx container generates its configuration by replacing ${WEBSERVER_HOST} and ${PEERTUBE_HOST} from your environment file, so make sure the domain in .env is correct before the containers first run.

Next, issue the first TLS certificate manually with Let’s Encrypt:

mkdir -p docker-volume/certbot
docker run -it --rm --name certbot -p 80:80 -v "$(pwd)/docker-volume/certbot/conf:/etc/letsencrypt" certbot/certbot certonly --standalone

Expected result: the certificate lands in docker-volume/certbot/conf, and a dedicated container inside Compose renews it automatically and reloads Nginx afterwards. If this command fails, the cause is almost always a domain not yet pointing at this VPS, or port 80 already in use by another service.

Step 4: Start PeerTube and collect the admin password

Start the containers in the background:

docker compose up -d

Then watch the PeerTube logs:

docker compose logs -f peertube

Expected result: PeerTube connects to PostgreSQL and Redis, then finishes initialisation. The administrator account root is created automatically with a random password. Pull that password from the logs:

docker compose logs peertube | grep -A1 root

The output should look roughly like this:

Username: root
User password: <random-password>

Log in promptly at https://video.example.com with the root account, change its password, and create a separate regular user account for day-to-day uploads. The root account should be reserved for administration. If you ever forget the admin password, reset it from the project folder with the official command:

docker compose exec -u peertube peertube npm run reset-password -- -u root

Step 5: Test with one video before opening registration

Do not announce your instance yet. Upload one short video from the regular user account, let transcoding finish, then play the result on another device and on a different connection speed. Watch three things: whether every resolution you enabled was produced, how long transcoding took for a video of that length, and how large the total output is compared with the original file.

That test gives you your real planning numbers. If a 10-minute video takes uncomfortably long to transcode on your VPS, an archive of 100 videos will not finish overnight — and that is more useful information than any spec sheet. After that, decide from the admin panel: which resolutions to keep, whether registration stays open or invitation-only, and whether federation is switched on or the instance stays standalone.

On federation, honestly: switching it on means your instance starts exchanging data with other instances, following and being followed, and that adds moderation load. An instance following many others will receive metadata and activity queues from outside. For a first instance, the calmest choice is to start closed — federation off — until your upload, transcoding, and backup routines have proven themselves. Opening federation later is far easier than cleaning up a moderation mess that already came in.

Backups and upgrades: the two things deferred until too late

Back up three things separately: the PostgreSQL database, the video and configuration folders, and the .env file plus the Nginx template. Losing any one of them turns recovery into guesswork. For the database, a dump command can be run from inside the container from the project folder, and that dump archive must itself be stored off the VPS.

For upgrades, read the PeerTube changelog first, especially its important-notes section, before pulling new images. The official upgrade sequence is to pull the latest images, stop the containers, then run them again:

cd ~/peertube
docker compose pull
docker compose down -v
docker compose up -d

Note: docker compose down -v removes internal volumes, as the official upgrade guide directs, so that static client files shared between the PeerTube and web server containers do not go stale. That is why your backups must be complete before running this — do not run an upgrade as a first step just to “see what happens”.

Troubleshooting

SymptomLikely causeFix
Certificate issuance failsDomain not pointing at the VPS, or port 80 in useCheck DNS and free port 80 before running Certbot
PeerTube cannot connect to the databaseCredentials in .env mismatch, or placeholders left in placeRecheck the five values replaced in Step 2
root password not foundLogs already rolled over, or initialisation not finishedWait for initialisation, repeat the log grep, or use reset-password
Transcoding very slow, queue backing upNot enough CPU for the enabled resolutionsReduce transcoded resolutions, space out uploads, or upgrade the VPS
Videos unplayable after a domain changeThe PeerTube domain is finalRevert to the original domain; host changes are not officially supported
Disk suddenly fullHLS and Web Video both enabled, or archive growingDisable one playback method or unused resolutions; monitor disk usage

Summary table

ComponentValue used
Install methodOfficial Docker Compose setup from the PeerTube repository
Main servicesPeerTube, PostgreSQL, Redis, and Nginx web server
Internal app port9000 (behind Nginx)
Public ports80 for certificates, 443 for viewers; 1935 if RTMP live streaming is enabled
Initial admin accountroot, random password from logs, resettable via reset-password
DomainFinal from first start, not supported to change
Heaviest loadVideo transcoding (CPU and disk), not web pages

Final checklist

  • Final domain decided and pointing at the VPS.
  • All five .env placeholders replaced.
  • TLS certificate issued and Nginx serving HTTPS.
  • root password changed and a separate uploader account created.
  • One test video transcoded and played through to the end.
  • Transcoding resolutions trimmed to real needs.
  • Backups of the database, video folders, and .env scheduled.

What kind of video would you host yourself first — a tutorial archive, class recordings, or internal documentation? And how large is the archive already waiting to move? Share it in the comments, so a follow-up on storage and transcoding can work with realistic numbers.

Read also:

For the companion self-hosted communication topic on the same VPS, read the Matrix Synapse guide in this batch: https://blog.rnevio.com/2026/11/how-to-install-matrix-synapse-on-vps.html. If you like managing media yourself on your own server, the Rnevio article “Jellyfin: Media Server Pribadi Gratis, Nonton Koleksi Sendiri di Mana Saja” covers the local-collection playback side that complements PeerTube.

Diskusi

Ada pertanyaan atau pengalaman yang ingin dibagikan?

0komentar

Komentar ditinjau sebelum ditampilkan. Mari berdiskusi dengan sopan dan sesuai topik.