PhotoStructure for Docker Compose
These are instructions for advanced users, wanting to run PhotoStructure for Servers via Docker Compose.
Before you begin… #
Please read the first sections of the PhotoStructure for Docker installation instructions.
Make sure you understand:
- PhotoStructure’s required docker
volumes (
/ps/library
,/ps/tmp
, …) - How to add (and ignore) directories to be imported into your library
- Volume UUIDs
- Networking setup
Example Docker Compose setup #
Copy the following into a docker-compose.yml
file in a new directory. Note
that the directory name becomes the prefix for the container.
See the docker-compose documentation for more details.
Please change the lines that say CHANGE THIS LINE to values that make sense for your setup.
version: "3.7"
services:
photostructure:
image: photostructure/server
restart: on-failure
stop_grace_period: 2m
user: 1000:1000 # < If you need a different user id, see below
volumes:
# This is where your PhotoStructure Library will be stored.
# It must be readable, writable, and have sufficient free space.
# If it is a remote volume, uncomment the PS_FORCE_LOCAL_DB_REPLICA
# environment line below.
- type: bind
source: /mnt/media/PhotoStructure # < CHANGE THIS LINE
target: /ps/library
# This must be fast, local disk with many gigabytes free.
# PhotoStructure will use this directory for file caching
# and for storing a temporary database replica when your
# library is on a remote volume.
- type: bind
source: "${HOME}/.cache/photostructure"
target: /ps/tmp
# This directory stores your "system settings"
- type: bind
source: "${HOME}/.config/PhotoStructure-docker"
target: /ps/config
# This directory stores PhotoStructure logfiles.
- type: bind
source: "${HOME}/.config/PhotoStructure/logs"
target: /ps/logs
# Example additional directories to import into your library.
# Add as many as you'd like, or remove one or both of these examples.
# Set the target to /media/... or /mnt/...
# (the name doesn't matter, as long as it is unique)
- type: bind
source: "/mnt/Photos backup" # < CHANGE THIS LINE
target: /var/photos-backup
# Here's another example directory to scan:
# - type: bind
# source: /home/jamie/Pictures
# target: /var/home-jamie-pictures
ports:
- 1787:1787/tcp
environment:
# PhotoStructure has _tons_ of settings. See
# <https://photostructure.com/faq/environment-variables/>
# This tells PhotoStructure to only log errors, which is the default:
- "PS_LOG_LEVEL=error"
labels:
# See https://containrrr.dev/watchtower/container-selection/
- "com.centurylinklabs.watchtower.enable=true"
watchtower:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
# Check for updates every couple hours: (3h * 60m * 60s)
command: --interval 10800
environment:
- "WATCHTOWER_LABEL_ENABLE=true"
Running PhotoStructure with different userids or groupids #
The photostructure/server
image is set up to run with a user and group id of
1000
. If you need to use a different userid, you’ll need to use Docker’s
userns-remap
feature.
Set up your bind mounts #
Docker fails if bind mount sources don’t exist. If you used the defaults in the above config, run this:
mkdir -p "${HOME}/.cache/photostructure" \
"${HOME}/.config/PhotoStructure-docker" \
"${HOME}/.config/PhotoStructure/logs"
Start PhotoStructure #
cd
into the directory with your docker-compose.yml
, and then run:
docker-compose up --detach
Then open http://localhost:1787
in a browser to complete the installation.
Firefox, Chrome, and Safari are supported.
While you wait for your import to complete, check out these getting-started tips!
Stop PhotoStructure #
cd
into the directory with your docker-compose.yml
, and then run:
docker-compose down
If you’re wondering why it’s taking a while to shut down, this is why.
Adding and removing volumes to import into your library #
To add or remove volumes to synchronize or import into your PhotoStructure library, just
docker-compose down
- Edit your
docker-compose.yml
and add or remove new bind mounts docker-compose up
PhotoStructure will detect the new volumes automatically and import them when you restart.
How to upgrade PhotoStructure #
Upgrades are automatic if you use Watchtower (as configured in the example)!
If you disabled Watchtower, cd
into the directory with your docker-compose.yml
, and then run:
docker-compose down
docker-compose pull
docker-compose up --detach
Uninstalling PhotoStructure #
cd
into the directory with your docker-compose.yml
, and then run:
docker-compose down
docker-compose rm
As you see fit, remove your library, config, tmp and logs volumes. Take care not
to delete photos and videos you want to keep! If you want to keep the originals
in your library, but remove PhotoStructure’s preview images and videos, you can
safely delete the $LIBRARY/.photostructure/previews
directory.