# PhotoPrism Photo Management

> PhotoPrism AI-powered photo management.

- Category: Media & Entertainment
- Difficulty: intermediate
- Components: photoprism, mariadb, redis
- Tags: photos, ai, gallery, machine-learning
- Source: https://docker.recipes/media/photoprism-photos-stack

## Overview

PhotoPrism is an AI-powered photo management application that uses TensorFlow for automatic image tagging, face recognition, and intelligent organization of photo libraries. Originally developed as a privacy-focused alternative to cloud photo services, PhotoPrism processes RAW files, performs automatic categorization, and creates searchable photo archives without sending data to external services. This stack combines PhotoPrism with MariaDB for metadata storage and Redis for caching and session management, creating a complete photo management solution that can handle large photo collections with fast search and browsing capabilities. The MariaDB database stores all photo metadata, tags, and user information while Redis accelerates the application by caching frequently accessed data and managing user sessions. This combination ensures that PhotoPrism can quickly serve photo galleries, perform complex searches, and handle multiple concurrent users efficiently. This configuration is ideal for photographers, families, and organizations who want to maintain complete control over their photo data while benefiting from modern AI-powered organization features. Unlike cloud-based solutions, this stack keeps all photos and metadata on your own infrastructure, making it perfect for privacy-conscious users and professional photographers who need reliable local storage with advanced search capabilities.

## Features

- AI-powered automatic tagging using TensorFlow for object and scene recognition
- Facial recognition with automatic people clustering and identification
- Interactive map visualization showing photo locations and geotagging
- Color-based search allowing users to find photos by dominant colors
- RAW file processing supporting professional camera formats from Canon, Nikon, Sony, and others
- Live photo support with automatic pairing of images and video components
- WebDAV synchronization for automatic photo backup from mobile devices
- Advanced search capabilities including date ranges, camera settings, and AI-generated tags

## Use cases

- Professional photographers managing large RAW photo collections with automatic cataloging
- Family photo archiving with automatic face recognition to organize pictures by family members
- Photography studios providing clients with private photo galleries and sharing capabilities
- Travel photographers using GPS data for automatic location-based photo organization
- Wedding photographers delivering organized galleries with automatic couple and guest recognition
- Stock photography management with AI-generated tags for efficient keyword searching
- Corporate photo archives requiring privacy compliance and local data storage

## Prerequisites

- Minimum 4GB RAM recommended for AI processing and photo indexing operations
- Available port 2342 for PhotoPrism web interface access
- Sufficient storage space for both original photos and PhotoPrism's generated thumbnails and metadata
- Basic understanding of photo file formats and directory structures for organizing import folders
- Docker host with adequate CPU power for TensorFlow-based image analysis and face recognition
- Network access for initial setup and potential future updates to AI models

## docker-compose.yml

```yaml
services:
  photoprism:
    image: photoprism/photoprism:latest
    container_name: photoprism
    restart: unless-stopped
    ports:
      - "${PHOTOPRISM_PORT:-2342}:2342"
    environment:
      - PHOTOPRISM_ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - PHOTOPRISM_DATABASE_DRIVER=mysql
      - PHOTOPRISM_DATABASE_SERVER=mariadb:3306
      - PHOTOPRISM_DATABASE_NAME=photoprism
      - PHOTOPRISM_DATABASE_USER=photoprism
      - PHOTOPRISM_DATABASE_PASSWORD=${DB_PASSWORD}
      - PHOTOPRISM_REDIS_HOST=redis
    volumes:
      - photoprism_storage:/photoprism/storage
      - ${PHOTOS_PATH:-./photos}:/photoprism/originals
    depends_on:
      - mariadb
      - redis

  mariadb:
    image: mariadb:11
    container_name: photoprism-db
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
      - MYSQL_DATABASE=photoprism
      - MYSQL_USER=photoprism
      - MYSQL_PASSWORD=${DB_PASSWORD}
    volumes:
      - mariadb_data:/var/lib/mysql

  redis:
    image: redis:7-alpine
    container_name: photoprism-redis
    restart: unless-stopped

volumes:
  photoprism_storage:
  mariadb_data:
```

## .env

```bash
# PhotoPrism
PHOTOPRISM_PORT=2342
ADMIN_PASSWORD=photoprism_admin
PHOTOS_PATH=./photos
DB_PASSWORD=photoprism_db
DB_ROOT_PASSWORD=root_password
```

## Usage notes

- PhotoPrism at http://localhost:2342
- Login with admin credentials
- Mount photos directory for import
- AI indexing runs automatically

## Troubleshooting

- PhotoPrism shows 'database connection failed': Verify MariaDB container is running and MYSQL_PASSWORD matches PHOTOPRISM_DATABASE_PASSWORD in environment variables
- AI indexing is slow or fails: Increase Docker memory limits as TensorFlow requires substantial RAM for image processing and face recognition
- Photos not appearing after import: Check that the PHOTOS_PATH directory has proper read permissions and PhotoPrism can access mounted volume
- Redis connection errors in logs: Ensure Redis container is healthy and PHOTOPRISM_REDIS_HOST points to correct container name
- Face recognition not working: Verify PhotoPrism has sufficient memory allocation and restart indexing after increasing container resources
- MariaDB fails to start with 'data directory not empty': Remove mariadb_data volume or ensure consistent MySQL credentials across container restarts

