PhotoPrism is a web-based photo management application. It automatically detects objects, locations, and labels. It is a promising self-hosted Google Photos alternative. Photoprism can be installed on Docker as a container. In this tutorial we will install Photoprism on Docker and load an existing collection of photos.
Installing Photoprism Docker container
Make sure you have installed Portainer & Docker before proceeding. We will add a docker stack of PhotoPrism with MariaDB as a data store.
1. On Portainer, add a new stack with name PhotoPrism. Leave the Build method as Web Editor.
2. Copy the below compose file content into the Web editor. Do not deploy the stack yet, I’ll explain what each configuration does in the following steps. You can customize if needed.
--- version: '2' services: mariadb: image: mariadb container_name: mariadb restart: unless-stopped command: mysqld --transaction-isolation=READ-COMMITTED --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=512 --innodb-rollback-on-timeout=OFF --innodb-lock-wait-timeout=50 volumes: - "/opt/container/mariadb/storage:/var/lib/mysql" environment: MYSQL_ROOT_PASSWORD: changeme MYSQL_DATABASE: photoprism MYSQL_USER: photoprism MYSQL_PASSWORD: changeme network_mode: bridge photoprism: image: photoprism/photoprism:latest container_name: photoprism ports: - 2342:2342 environment: PHOTOPRISM_HTTP_PORT: 2342 PHOTOPRISM_ADMIN_PASSWORD: "changeme" PHOTOPRISM_DATABASE_DRIVER: "mysql" PHOTOPRISM_DATABASE_SERVER: "mariadb:3306" PHOTOPRISM_DATABASE_NAME: "photoprism" PHOTOPRISM_DATABASE_USER: "photoprism" PHOTOPRISM_DATABASE_PASSWORD: "changeme" PHOTOPRISM_SITE_URL: "http://localhost:2342/" PHOTOPRISM_SITE_TITLE: "PhotoPrism" PHOTOPRISM_SITE_CAPTION: "Browse Your Life" volumes: - "/opt/container/photoprism//import:/photoprism/import" - "/opt/container/photoprism/storage:/photoprism/storage" - "/mnt/share/photos:/photoprism/originals" restart: unless-stopped network_mode: bridge
MariaDB Database container
3. We will configure a DB store in MariaDB for PhotoPrism to use. Start with setting the listening port (default:3306) for the container.
4. Set a storage location for MariaDB application data.
5. Add a root password for mysql.
6. Create a user and database for PhotoPrism. We will use them again in the PhotoPrism settings.
7. The default Container port is 2342 if you need change it at the two highlighted places (This is something I rarely do). This container port can be mapped onto a different host port, I set that also to 2342 here.
8. Now set your web UI administration password. As far as I know there is no user management in this version. You only have an admin user for access.
9. Next, add the mariadb connection info and user credentials we entered earlier in MariaDB.
10. You can set either an external or internal site URL using the PHOTOPRISM_SITE_URL variable. This will be used when you share the photos with others. I am not going to share this outside so I am leaving it as localhost.
11. Additionally, volumes are required to store imported images (/photoprism/import), and other metadata (/photoprism/storage)used by PhotoPrism container.
You can also add existing images under /photoprism/originals.
12. Deploy Stack once everything above is done, portainer will install two containers and start them.
13. Go to http://localhost:2342 on your browser, and login with the admin credentials you set earlier.
14. To load existing images you have to re-index the library. Go to Library, hit Start to initiate indexing.
You can re-index if you happen to add more files to the originals folder. If you upload or import via the interface it happens automatically.
That is it! PhotoPrism is ready and now you can view all your images under photos.