I recently wanted to switch from Google Photos to Immich and while doing so I stumbled across some difficulties while adding the photo’s on my NAS as an external library. In the past 20+ years I organized my library by hand without relying on any tools, so I did not want Immich to make any changes to my photo library, hence I mounted the Samba share as read-only.
//nas.internal/photo /mnt/photo cifs credentials=/root/samba.cred,ro,nodev,noexec,nosuid,gid=0,dir_mode=0777,file_mode=0444 0 0
If I try to add a folder from this share as an external library I get the following error: “Lacking read permissions for folder”

Disabling SELinux would fix the issue, but even if the instance is not publicly available, it’s still a bad idea to disable any security measures. So we need to tell SELinux it’s fine for the container to access the share. Usually this is done by appending :z to the volume:
services:
immich-server:
container_name: immich_server
image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
# extends:
# file: hwaccel.ml.yml
# service: vaapi # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
volumes:
# Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file
- /var/immich/media/:/usr/src/app/upload:z
- /etc/localtime:/etc/localtime:ro
- /mnt/photo:/usr/src/app/external:z
env_file:
- immich.env
ports:
- '2283:2283'
depends_on:
- database
restart: always
healthcheck:
disable: false
But simply adding “:z” in the Docker compose file won’t work for two reasons:
- The user does not have any root privileges to change the SELinux context
- The filesystem is mounted read-only and changing the context is a write operation
Luckily, we can mount the SMB share with an SELinux content which will allow the container to access the files:
//nas.internal/photo /mnt/photo cifs credentials=/root/samba.cred,ro,nodev,noexec,nosuid,gid=0,dir_mode=0777,file_mode=0444,context="system_u:object_r:container_file_t:s0" 0 0
To apply the changes we need to unmount/remount the share
# stop the immich containers first
podman compose down
# Remount (mount -o remount won't work, remount can't change permissions)
sudo umount /mnt/photo
sudo mount /mnt/photo
If we now restart Immich and add the Samba share we can see that it can access the files:
