DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
DocumentaryTube
24/7 streaming

How to Use Docker Compose to Run a 24/7 YouTube Stream on Hetzner

A practical guide to running a YouTube encoder with Docker Compose on Hetzner, including setup, credentials, testing, recovery and failure limits.

By DocumentaryTube Team 8 min read
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can use Docker Compose to keep a YouTube encoder process running on a Hetzner Cloud server, but Compose alone does not guarantee a healthy, uninterrupted broadcast. You still need an enabled YouTube Live channel, an encoder configured for YouTube’s ingest settings, protected credentials, and monitoring that can detect problems a container restart will not fix.

What you need before you start

  • A YouTube channel that is verified, has live streaming enabled, and has no live-streaming restriction in the last 90 days. First-time activation can take up to 24 hours.
  • A Hetzner Cloud account and a server suitable for the encoder workload you intend to run.
  • An encoder that can read your source video and send a supported live feed to YouTube. The exact image, command and configuration depend on the encoder you choose.
  • A source recording or other media that the encoder can access, plus a plan for how it should play or repeat.

Do not choose a server size based on a universal CPU or memory rule: the required resources depend on the source, resolution, frame rate, codec and any filters. Test the actual workload before relying on it.

1. Enable YouTube Live and get the stream credentials

  1. Open YouTube Studio and confirm that live streaming is available for your channel. If you are enabling it for the first time, allow up to 24 hours for activation.
  2. Create or select a stream in YouTube Studio’s Live Control Room. Copy the server URL and stream key shown for that stream into the encoder’s configuration.
  3. Treat the stream key like a password. Do not commit it to a repository, paste it into a publicly shared Compose file, or print it in logs. If it is exposed, reset it through Live Control Room and update the encoder configuration.

YouTube recommends RTMPS for secure ingestion. Configure your chosen encoder to use the server URL and key supplied by YouTube rather than guessing an ingest address.

2. Create a Hetzner Cloud server

Hetzner’s Docker CE app is an option if you want Docker and the Compose plugin preinstalled; its documented base image is Ubuntu 24.04. Verify the app image and its current details when creating the server. You can instead install Docker and Compose using their current official instructions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

The evidence available here does not establish a minimum server size or a current price for a 24/7 encoding workload. Start with a server you can test, then check CPU, memory, network and encoder behavior with the same media and settings you expect to use in production. Software encoding, hardware encoding and different source formats can have different resource demands.

3. Protect server access and credentials

  • Review the Hetzner firewall before deployment. Hetzner’s Cloud API documentation states that a firewall with no inbound rule drops inbound traffic.
  • Allow only the inbound administration access you need, and restrict SSH to trusted sources where possible.
  • An encoder that sends an outbound connection to YouTube ordinarily does not need a public streaming listener. Do not expose one unless your chosen architecture specifically requires it.
  • Keep the YouTube key in a protected runtime file or an appropriate secret mechanism for your host and Compose implementation. Compose secrets are mounted as files, but provisioning them is platform-specific.

4. Define the service with Docker Compose

Compose describes how the encoder service is started and gives you repeatable lifecycle, status and log commands. Your Compose file needs an image supported by your selected encoder, an explicit command and configuration for that encoder, a restart policy, and mounts for media or configuration that must remain available if the container is replaced.

The following is a structural example, not a runnable encoder configuration: the image and command must be chosen for your encoder, and the encoder must be configured separately with the source media and YouTube output credentials.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
services:
  streamer:
    image: ENCODER_IMAGE_AND_TAG
    command: ENCODER_SPECIFIC_COMMAND
    restart: unless-stopped
    volumes:
      - ./media:/media:ro
      - ./config:/config:ro

Replace the two capitalized values with a deliberately managed image and the command supported by that image. Mount your actual source and configuration paths as needed; do not put a live stream key in the example file. Pin or deliberately manage image versions so a change in the image does not surprise a running deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

From the directory containing the Compose file, use these commands:

  • docker compose up -d starts the service in the background.
  • docker compose ps shows the service status.
  • docker compose logs -f streamer follows the service logs; stop following with Ctrl-C without stopping the service.

If you edit the Compose configuration or environment values, recreate or update the service so the changes are applied. docker compose restart only restarts the existing container; it does not apply changed Compose configuration or environment values.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

5. Configure the encoder for YouTube

Use the encoder’s own settings or command syntax to select the media source, video and audio formats, stream destination, and YouTube stream key. The exact command is image- and encoder-specific; a Compose restart policy cannot substitute for correct encoder configuration.

Video, audio and connection settings

  • YouTube’s guidance identifies H.264 video and AAC audio in its documented incorrect-format error. Check that the chosen encoder’s output matches formats accepted by YouTube.
  • Set the output resolution, frame rate, video bitrate and audio bitrate to values the source and server can sustain. YouTube’s streaming tips recommend upload capacity with 20% headroom above the total stream bitrate; count primary and backup bitrates where applicable.
  • Use RTMPS when configuring the ingest destination if supported by the encoder.
  • Choose keyframe and other codec settings using the current YouTube guidance and your encoder’s documentation. Do not assume a sample setting from another encoder applies unchanged.

Because the required bitrate and server size depend on the actual stream, do a representative test with similar motion and audio before leaving the feed unattended.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

6. Test the stream before depending on it

  1. Start the Compose service and inspect docker compose ps and docker compose logs -f streamer for startup errors.
  2. Open YouTube Live Control Room and check the incoming preview, stream health and audio/video quality. Confirm that the intended source is playing rather than merely checking that the container is running.
  3. Check playback from the watch page and a mobile device, and verify that the stream remains healthy during representative content and motion.
  4. Test recovery deliberately. Confirm what happens when the encoder process exits, the source file is unavailable, the network drops, or YouTube rejects the credentials or ingest connection.

A restart policy can start a stopped container again, but it may not detect a frozen source, an invalid key, an ingest failure, or a process that remains alive while sending unusable output. Monitor the stream at the encoder and YouTube ends, and define how you will be alerted and respond when output is unhealthy.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2Ă— USB C male to USB A female adapters and 2Ă— USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

7. Understand restart, recovery and failover

restart: unless-stopped tells Docker how to handle a stopped container; it is not a second encoder, a guarantee of server availability, or proof that YouTube is receiving good video. If continuous output is important, plan an independent backup path and test switching to it. YouTube recommends exercising backup-encoder failover for event workflows.

Consider the failure domains separately: a container can restart while the server is healthy, but a server outage, source-media problem, credential error or YouTube ingest problem may require a different recovery action. Write down how to check each part and how to bring the stream back after an interruption.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

8. Plan for long broadcasts and archives

YouTube states that streams under 12 hours are automatically archived. That does not establish that a single event can run indefinitely or what exactly happens to an event that exceeds 12 hours. For a very long broadcast, plan a restart or segmentation approach and confirm YouTube’s current behavior before relying on a single event running beyond that duration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Common problems and what to check

Symptom Likely checks Action
Container exits or repeatedly restarts Inspect docker compose ps and the service logs for an invalid command, image issue or missing mounted file. Correct the encoder-specific command or mount, then recreate the service if Compose configuration changed.
Container is running but YouTube shows no healthy video Check the Live Control Room preview and stream health, the ingest URL, key, source playback and encoder output. Fix the encoder or source issue; a running container by itself is not evidence of a working stream.
YouTube reports an incorrect format Check that video and audio output use supported formats; YouTube identifies H.264 video and AAC audio in its documented format error. Change the encoder output settings and retest in Live Control Room.
Stream becomes unstable under load Compare actual server load and upload capacity with the selected source, resolution, frame rate, filters and total stream bitrate. Test the workload with adequate capacity; YouTube recommends 20% upload headroom over total stream bitrate.
Updated Compose values appear to have no effect Check whether only docker compose restart was run. Recreate or update the service so Compose applies the changed configuration or environment.
Key is exposed or rejected Check that the encoder uses the current key and that it has not been shared or logged. Reset an exposed key through YouTube Live Control Room and replace the encoder’s stored value.

Cost and deployment trade-offs

A Hetzner server gives you a self-managed environment for Docker and your chosen encoder, but the appropriate server size and its cost depend on the workload and current Hetzner offerings. The available evidence does not establish a universal instance recommendation or price. A local machine avoids renting that cloud compute but must remain powered and connected; neither approach removes the need to monitor the actual stream.

A single encoder service is simpler than operating independent primary and backup encoders, but it does not provide a separate failover path. If stream continuity matters, treat redundancy as a separate design decision and test it rather than assuming that Docker’s restart behavior supplies it.

Or let it run in the cloud

If you want a managed option instead of maintaining a Hetzner server and Compose stack, StreamNeo keeps an uploaded video or playlist live on YouTube from the cloud: upload your recording, add your YouTube stream key once, then go live. Nothing has to stay on at home; it streams the video as uploaded, at any quality up to 4K 60fps for one flat price per slot, and automatically recovers if YouTube drops the stream. The first day is free with no card. Monthly pricing is $9.99 per month. In India, UPI works as well as cards. It is for uploaded videos and playlists, not a live camera feed, and streams to YouTube only. Start the free day with StreamNeo.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Screening Room

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.