Install Photoprism on Docker

by RamWise
Published: Last Updated on 5,196 views

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 containerIn 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.

PhotoPrism container

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. 

7 comments

K April 14, 2021 - 3:18 pm

Great guide, thanks so much. Only problem for me is when I try to deploy the stack it pops up a red message box saying “Deployment error. Unable to deploy stack” with no other explanations. Any help with this would be appreciated.

Reply
ramwise April 28, 2021 - 10:37 pm

Thanks for commenting!
It is a generic error but make sure the “bridge” network exists. That’s the only situation I could think of causing an error.

Reply
Chunk August 31, 2021 - 6:14 am

thanks for many tutorials helping with the learning curve, Is it best to have separate mariadb containers for Photoprism and nextcloud? rather than sharing?

Reply
ramwise November 8, 2021 - 6:36 pm

I think you can go either way. Although, some like the idea of a completely independent group of containers for ease of management. I would recommend going by your use case.

Reply
Steven Raasch December 30, 2021 - 11:22 am

Thanks for this. Sorry for the noob question.
I get a failure on deployment that says there is a problem using the undefined network “bridge”. But this network does exist… What am I missing?

Reply
Steven Raasch December 30, 2021 - 6:09 pm

Kind of answered my own question… I was able to successfully get the container running by using network_mode:bridge, but that didn’t give me access to the containers from the host. By removing all network directives, the containers fell back to using the default bridge (https://netcraftsmen.com/docker-networking/#:~:text=By%20default%2C%20containers%20on%20a%20host%20all%20connect%20to%20the%20default%20bridge%20docker0%2C%20and%20all%20ports%20on%20them%20are%20exposed%20(published)%20to%20the%20outside%20world.) which worked for me.

Reply
RamWise January 4, 2022 - 7:50 pm

Thank you so much! yours is the more correct solution for this. I am going to update my compose script accordingly.

Reply

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More