Knowledge Base > Privacy & Self-Hosting > Frigate NVR with Docker

Self-Hosted Frigate NVR with Docker

Your cameras, your server, your recordings


Frigate is a self-hosted network video recorder (NVR) built around real-time AI object detection. It watches your camera feeds, detects people, cars, animals, and other objects, and records only the events that matter. No cloud subscriptions, no footage leaving your network, and full control over your data.

This guide walks you through installing Frigate in a Docker container on Ubuntu Server, connecting it to an MQTT broker for Home Assistant integration, configuring your firewall, and adding cameras.

Companion Guide

Frigate works best when paired with Home Assistant. If you need to set up Home Assistant with MQTT and Frigate integration, see our Home Assistant with MQTT and Frigate Integration guide.


Architecture

+------------------------------------------+
|  Frigate Server                          |
|                                          |
|  +------------------------------------+  |
|  | Frigate Container                  |  |
|  |                                    |  |
|  |  :8971  - Web UI (HTTPS)           |  |
|  |  :8554  - RTSP re-streams          |  |
|  |  :8555  - WebRTC (TCP+UDP)         |  |
|  +------------------------------------+  |
+------------------------------------------+
                    |
                    | MQTT (1883)
                    v
+------------------------------------------+
|  Home Assistant Server                   |
|                                          |
|  +----------------+  +----------------+  |
|  | Home           |  | Mosquitto      |  |
|  | Assistant      |  | MQTT Broker    |  |
|  | :8123          |  | :1883          |  |
|  +----------------+  +----------------+  |
+------------------------------------------+

Frigate runs on its own server. It connects to an MQTT broker (Mosquitto) running on the Home Assistant server. When Frigate detects an object, it publishes events over MQTT, and Home Assistant picks them up. All traffic stays on your local network.


Prerequisites

Server Requirements

ResourceMinimumRecommended
CPU2 vCPUs4 vCPUs
RAM2 GB4 GB+
Disk30 GB50 GB+ (depends on retention)
OSUbuntu 24.04 LTS Server (or similar)

You need a Linux server with Docker installed and SSH access. If you need help installing Docker, see the Docker installation section in our Forgejo guide or the official Docker docs.

Network Requirements

  • A static IP address for your Frigate server
  • An MQTT broker accessible on your network (e.g., Mosquitto on your Home Assistant server)
  • IP cameras with RTSP stream support
  • Ports 8971, 8554, and 8555 available on your LAN

Throughout this guide, example IPs use 192.168.1.100 for the Frigate server and 192.168.1.50 for the Home Assistant/MQTT server. Replace these with your actual values.


Step 1: Create Directory Structure

mkdir -p ~/frigate/config
mkdir -p ~/frigate/storage

The directory layout:

~/frigate/
+-- docker-compose.yml
+-- config/
|   +-- config.yml          # Frigate configuration
+-- storage/                 # Media storage (recordings, snapshots, exports)
    +-- clips/               # (auto-created)
    +-- recordings/          # (auto-created)
    +-- exports/             # (auto-created)

Step 2: Create Docker Compose File

nano ~/frigate/docker-compose.yml

Paste the following:

services:
  frigate:
    container_name: frigate
    privileged: true
    restart: unless-stopped
    stop_grace_period: 30s
    image: ghcr.io/blakeblackshear/frigate:stable
    shm_size: "512mb"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./config:/config
      - ./storage:/media/frigate
      - type: tmpfs
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "8971:8971"
      - "8554:8554"
      - "8555:8555/tcp"
      - "8555:8555/udp"
    environment:
      FRIGATE_RTSP_PASSWORD: "your_password_here"

Replace your_password_here with a password for RTSP re-streams. Save and exit.

What These Settings Do

  • privileged: true - Required for device access (USB Coral, GPU passthrough)
  • stop_grace_period: 30s - Gives Frigate time to cleanly shut down all sub-processes
  • shm_size: "512mb" - Shared memory for decoded video frames. Increase if you add many cameras.
  • tmpfs (1 GB) - In-memory cache for recording segments before conversion. Reduces disk writes and improves performance.
  • FRIGATE_RTSP_PASSWORD - Used in camera RTSP URLs via {FRIGATE_RTSP_PASSWORD} variable substitution

Ports

PortProtocolPurpose
8971TCPWeb UI (HTTPS, self-signed certificate)
8554TCPRTSP re-streams
8555TCP + UDPWebRTC streams

Step 3: Create Frigate Configuration

nano ~/frigate/config/config.yml

Start with a minimal configuration:

mqtt:
  enabled: true
  host: 192.168.1.50
  port: 1883

detectors:
  cpu1:
    type: cpu
    num_threads: 2

cameras: {}

version: 0.17-0

Replace 192.168.1.50 with the IP of your MQTT broker (typically your Home Assistant server). Set num_threads to match your vCPU count.

We start with no cameras configured. You can add them after verifying the base install works.


Step 4: Configure Firewall

Lock down the server so only your local network can access Frigate's services.

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from 192.168.1.0/24 to any port 22 proto tcp comment 'SSH from LAN'
sudo ufw allow from 192.168.1.0/24 to any port 8971 proto tcp comment 'Frigate Web UI from LAN'
sudo ufw allow from 192.168.1.0/24 to any port 8554 proto tcp comment 'Frigate RTSP from LAN'
sudo ufw allow from 192.168.1.0/24 to any port 8555 comment 'Frigate WebRTC from LAN'
sudo ufw enable

Replace 192.168.1.0/24 with your actual LAN subnet. Type y to confirm.

Verify:

sudo ufw status verbose

All rules should be scoped to your LAN subnet. No "Anywhere" rules.

Docker and UFW

Docker manipulates iptables directly for published ports, which can bypass UFW in some cases. The UFW rules provide host-level protection. For stricter Docker network control, consider configuring Docker's iptables setting or using the DOCKER-USER iptables chain.


Step 5: Start Frigate

cd ~/frigate
docker compose up -d

Verify the Container

docker compose ps

You should see a container named frigate with status Up and the correct port mappings.

Check Logs

docker compose logs -f

Watch for any errors. Press Ctrl+C to stop following.

Access the Web UI

https://YOUR_FRIGATE_IP:8971

Frigate uses HTTPS with a self-signed certificate. Accept the browser warning.

On first startup, Frigate generates an admin user. The default password is displayed in the container logs. Change it immediately after logging in under Settings > Users.

Use HTTPS

Frigate listens on HTTPS (port 8971), not HTTP. If you get a "400 Bad Request" error, make sure your URL starts with https:// not http://.


Adding Cameras

Edit ~/frigate/config/config.yml and add cameras under the cameras: key.

Example: Single Camera

cameras:
  front_door:
    ffmpeg:
      inputs:
        - path: rtsp://admin:password@CAMERA_IP:554/stream1
          roles:
            - detect
            - record
    detect:
      enabled: true
      width: 1280
      height: 720
      fps: 5
    record:
      enabled: true
      retain:
        days: 7
        mode: motion
    snapshots:
      enabled: true
      retain:
        default: 7

Replace CAMERA_IP, admin, and password with your camera's actual values. The RTSP path (/stream1) varies by camera manufacturer. Check your camera's documentation.

Using the Environment Variable for Passwords

Instead of hardcoding passwords in the config, use the FRIGATE_RTSP_PASSWORD environment variable from your compose file:

cameras:
  front_door:
    ffmpeg:
      inputs:
        - path: rtsp://admin:{FRIGATE_RTSP_PASSWORD}@CAMERA_IP:554/stream1
          roles:
            - detect

After Adding Cameras

cd ~/frigate
docker compose restart frigate

Calculating Shared Memory (shm_size)

For each camera, the formula is: width x height x 1.5 x 9 + 270480 bytes.

Example for a 1280x720 camera: 1280 x 720 x 1.5 x 9 + 270480 = 12,718,080 bytes (about 12.1 MB)

Add up all your cameras and round up. The default shm_size of 512 MB supports many cameras comfortably.


Home Assistant Integration

To connect Frigate to Home Assistant, you need three things on the Home Assistant side:

  1. MQTT integration configured in HA, pointing to your Mosquitto broker
  2. HACS (Home Assistant Community Store) installed
  3. Frigate integration installed via HACS, pointing to https://YOUR_FRIGATE_IP:8971

For the full walkthrough of setting up Home Assistant with MQTT and Frigate, see our Home Assistant with MQTT and Frigate Integration guide.

Once connected, Frigate cameras will automatically appear as devices in Home Assistant.


Hardware Acceleration

This guide uses CPU-based object detection. That works fine for testing and a small number of cameras, but it will use significant CPU with multiple streams. Here are your upgrade options:

AcceleratorPerformanceNotes
Google Coral USB~10ms inferenceBest value. Plug in USB and add device mapping.
Google Coral PCIe~5ms inferenceRequires PCIe passthrough if virtualized.
Intel iGPUVariesFor hardware-accelerated ffmpeg decoding. Requires GPU passthrough.

Adding a USB Coral

1. Connect the Coral USB accelerator to your server (or pass through from hypervisor)

2. Add the device to docker-compose.yml:

    devices:
      - /dev/bus/usb:/dev/bus/usb

3. Update the detector in config.yml:

detectors:
  coral:
    type: edgetpu
    device: usb

4. Restart Frigate:

cd ~/frigate
docker compose up -d

Managing Frigate

Service Commands

ActionCommand
Startcd ~/frigate && docker compose up -d
Stopcd ~/frigate && docker compose down
Restartcd ~/frigate && docker compose restart frigate
Logsdocker logs -f frigate
Statusdocker ps --filter name=frigate

Updating Frigate

cd ~/frigate
docker compose pull
docker compose up -d

Clean up old images afterward:

docker image prune -f

Troubleshooting

Frigate Will Not Start

docker logs frigate --tail 50

Common issues:

  • Port conflict: Another service is using 8971, 8554, or 8555. Check with sudo ss -tlnp | grep -E '8971|8554|8555'
  • Config validation error: Check logs for YAML syntax issues: docker logs frigate 2>&1 | grep -i "error\|invalid\|failed"
  • Disk full: Check with df -h

MQTT Connection Issues

Verify the MQTT broker is reachable:

sudo apt-get install -y mosquitto-clients
mosquitto_sub -h YOUR_MQTT_IP -t "frigate/#" -v

If this fails, check that Mosquitto is running on the HA server, the firewall allows port 1883, and network connectivity is working (ping YOUR_MQTT_IP).

High CPU Usage

CPU-based detection is resource-intensive. To reduce load:

  • Lower camera fps (e.g., from 5 to 3)
  • Reduce detect resolution
  • Add a Coral TPU (see Hardware Acceleration above)

Storage Filling Up

du -sh ~/frigate/storage/*
df -h

Reduce retention in config.yml:

record:
  retain:
    days: 3
    mode: motion

Web UI Shows "400 Bad Request"

You are using http:// instead of https://. Frigate requires HTTPS on port 8971.

Container Uses Too Much Memory

docker stats --no-stream

If memory is an issue, reduce shm_size in docker-compose.yml or reduce the number of cameras and resolution.


Resources