--- title: "How to Install PhotoPrism with Docker on Ubuntu 24.04" description: "Deploy PhotoPrism with Docker Compose and MariaDB on Ubuntu 24.04, publish it over HTTPS with Nginx, index your photo library and back up its database." category: "Media and Streaming Servers" language: en source: https://cubepath.com/docs/media-and-streaming-servers/photoprism-photo-management-installation updated: 2026-09-25 --- # How to Install PhotoPrism with Docker on Ubuntu 24.04 PhotoPrism is a self-hosted photo library that indexes your pictures, reads their EXIF metadata, detects faces and labels, and shows geotagged photos on a map, all without sending data to a third-party service. In this tutorial you will run PhotoPrism and MariaDB with Docker Compose on Ubuntu 24.04, put Nginx with a Let's Encrypt certificate in front of it, add photos to the library, and schedule indexing and database backups. ## Prerequisites To follow this guide you need: - A server running Ubuntu 24.04 LTS, for example a CubePath VPS, with at least 2 CPU cores and 4 GB of RAM. Indexing and face detection are CPU and memory intensive; with less RAM, add swap. - Enough disk space for your photos plus roughly 20-30% extra for thumbnails and sidecar files. - A non-root user with `sudo` privileges. - Docker Engine and the Docker Compose plugin installed. See [How to install Docker on Linux](/docs/docker-kubernetes/docker-installation-on-linux). - A domain name, referred to as `your_domain` (for example `photos.example.com`), with a DNS A record pointing to your server's public IP. ## Step 1 - Creating the project directory and secrets Keep everything PhotoPrism needs under `/opt/photoprism`: the Compose file, the database files, the generated cache (`storage`) and your photos (`originals`). ```bash sudo mkdir -p /opt/photoprism/{originals,import,storage,database} cd /opt/photoprism ``` Generate random passwords for the PhotoPrism admin account and the database, and store them in a `.env` file that Docker Compose reads automatically: ```bash sudo tee /opt/photoprism/.env > /dev/null < Note: `PHOTOPRISM_ADMIN_PASSWORD` is only used to create the admin account on the first start. To change the password later, use the web interface or `photoprism passwd admin` inside the container. ## Step 3 - Starting PhotoPrism Pull the images and start both containers in the background: ```bash cd /opt/photoprism sudo docker compose up -d ``` The first start takes a minute or two while MariaDB initializes and PhotoPrism creates its tables. Follow the log and press `Ctrl+C` once it settles: ```bash sudo docker compose logs -f photoprism ``` Check that both containers are running: ```bash sudo docker compose ps ``` Then query the status endpoint on the loopback port: ```bash curl -s http://127.0.0.1:2342/api/v1/status ``` ```output {"status":"operational"} ``` ## Step 4 - Configuring Nginx and HTTPS Install Nginx and Certbot from the Ubuntu repositories: ```bash sudo apt update sudo apt install nginx certbot python3-certbot-nginx ``` Create a server block for PhotoPrism: ```bash sudo nano /etc/nginx/sites-available/photoprism ``` ```nginx server { listen 80; listen [::]:80; server_name your_domain; client_max_body_size 500M; location / { proxy_pass http://127.0.0.1:2342; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_buffering off; proxy_read_timeout 600s; } } ``` The `Upgrade` and `Connection` headers are required because the PhotoPrism interface uses WebSockets for live updates. `client_max_body_size` allows large uploads from the browser. Enable the site, test the configuration and reload Nginx: ```bash sudo ln -s /etc/nginx/sites-available/photoprism /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl reload nginx ``` ```output nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful ``` Allow SSH, HTTP and HTTPS in UFW. Allow OpenSSH before enabling the firewall so you do not lock yourself out: ```bash sudo ufw allow OpenSSH sudo ufw allow 'Nginx Full' sudo ufw enable ``` Request a certificate. Certbot adds the TLS settings to the server block and redirects HTTP to HTTPS: ```bash sudo certbot --nginx -d your_domain ``` Open `https://your_domain` in your browser and log in as `admin` with the password from `/opt/photoprism/.env`. ## Step 5 - Adding photos and indexing the library PhotoPrism works with two folders: - `originals` is your library. PhotoPrism indexes files here in place and does not move them. Browser uploads also end up here. - `import` is a drop folder. The import command moves files from it into `originals`, sorted into folders by date, and skips duplicates. To add an existing collection, copy it into `originals`, for example with `rsync`: ```bash sudo rsync -a --info=progress2 /path/to/your/photos/ /opt/photoprism/originals/ ``` Then run the indexer. The first run reads metadata, generates thumbnails and runs label and face detection, so it can take hours on a large library: ```bash cd /opt/photoprism sudo docker compose exec photoprism photoprism index --cleanup ``` The `--cleanup` flag removes index entries for files that no longer exist. When the command returns, reload the web interface: your photos appear under **Search** and **Library**, and photos with GPS coordinates in their EXIF data appear under **Places**. To use the drop folder instead, place files in `/opt/photoprism/import` and run: ```bash sudo docker compose exec photoprism photoprism import ``` Both actions are also available in the web interface under **Library**. ## Step 6 - Scheduling indexing and database backups Files added to `originals` from outside the web interface (rsync, a sync client, a backup job) only appear after an index run. The database holds the index, albums, labels and people, so it needs its own backup. Create the backup script first. It dumps the database with the root password stored inside the MariaDB container, compresses the dump and keeps 14 days: ```bash sudo nano /usr/local/bin/photoprism-db-backup ``` ```bash #!/usr/bin/env bash set -euo pipefail backup_dir="/var/backups/photoprism" mkdir -p "$backup_dir" cd /opt/photoprism docker compose exec -T mariadb sh -c 'mariadb-dump -u root -p"$MARIADB_ROOT_PASSWORD" --single-transaction photoprism' \ | gzip > "$backup_dir/photoprism-$(date +%F).sql.gz" find "$backup_dir" -name 'photoprism-*.sql.gz' -mtime +14 -delete ``` Make it executable and run it once to test it: ```bash sudo chmod 750 /usr/local/bin/photoprism-db-backup sudo /usr/local/bin/photoprism-db-backup ls -lh /var/backups/photoprism ``` ```output -rw-r--r-- 1 root root 2.1M Sep 25 10:12 photoprism-2026-09-25.sql.gz ``` Now schedule both jobs with a cron file: ```bash sudo nano /etc/cron.d/photoprism ``` ```text # Index new and changed files every night at 03:00 0 3 * * * root cd /opt/photoprism && docker compose exec -T photoprism photoprism index --cleanup > /dev/null 2>&1 # Dump the database every night at 04:30 30 4 * * * root /usr/local/bin/photoprism-db-backup ``` Your photos themselves live in `/opt/photoprism/originals`. Include that folder and `/var/backups/photoprism` in your off-server backups. ## Step 7 - Updating PhotoPrism Run the backup script, then pull the new images and recreate the containers. PhotoPrism migrates its database schema on start: ```bash sudo /usr/local/bin/photoprism-db-backup cd /opt/photoprism sudo docker compose pull sudo docker compose up -d ``` ## Troubleshooting **Nginx returns 502 Bad Gateway.** PhotoPrism is not listening yet or has stopped. Check `sudo docker compose ps` and `sudo docker compose logs --tail 50 photoprism`. Database connection errors right after the first start usually mean MariaDB is still initializing; PhotoPrism retries on its own. **Indexing is very slow or the container restarts.** Check memory with `sudo docker stats` and look for out-of-memory kills with `sudo dmesg | grep -i oom`. Add RAM or swap. For a very large first run you can temporarily add `PHOTOPRISM_DISABLE_FACES: "true"` and `PHOTOPRISM_DISABLE_CLASSIFICATION: "true"`, run `sudo docker compose up -d`, index, then remove both settings and index again. **New files do not show up.** Files copied into `originals` from outside PhotoPrism only appear after an index run. Run the index command from Step 5 and read its output for unsupported or damaged files. **Uploads fail with "413 Request Entity Too Large".** Raise `client_max_body_size` in the Nginx server block and reload Nginx. ## Conclusion PhotoPrism now runs with Docker Compose and MariaDB behind Nginx with HTTPS, indexes your library every night and keeps two weeks of database dumps. As next steps, install PhotoPrism as a progressive web app on your phone from the browser menu, sync photos from a desktop through PhotoPrism's WebDAV endpoint, and copy `originals` and the database dumps off the server with a tool such as [restic](/docs/backup-recovery/backup-with-restic).