jails immich appjail

I am following:

I had immich running on podman and want to migrate it to a native appjail for perhaps marginally better performance and integration with FreeBSD.

That said, I had to deviate from the configuration because it for whatever reason isn't working and still isn't working for me:

.env:
Code:
UPLOAD_LOCATION=/media/immich/app-jail/app_data
DB_DATA_LOCATION=/media/immich/app-jail/postgres
CACHE_LOCATION=/media/immich/app-jail/cache
REDIS_DATA_LOCATION=/media/immich/app-jail/redis
TZ=Etc/UTC
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_DATABASE_NAME=immich
DIRECTOR_PROJECT=immich

Makejail:
Code:
OPTION container=boot args:--pull
OPTION overwrite=force

appjail-director.yml:
Code:
options:
  - alias:
  - ip4_inherit:

services:
  immich-server:
    name: immich_server
    priority: 100
    options:
      - from: ghcr.io/daemonless/immich-server:latest
    volumes:
      - immich-data: /data

    oci:
      environment:
        - DB_HOSTNAME: 127.0.0.1
        - DB_USERNAME: ${DB_USERNAME}
        - DB_PASSWORD: ${DB_PASSWORD}
        - REDIS_HOSTNAME: 127.0.0.1
        - IMMICH_MACHINE_LEARNING_URL: [URL]http://127.0.0.1:3003[/URL]
        - TZ: ${TZ}

  immich-machine-learning:
    name: immich_machine_learning
    options:
      - from: ghcr.io/daemonless/immich-ml:latest
    oci:
      environment:
        - HF_HOME: /cache/huggingface
        - MPLCONFIGDIR: /tmp
        - TZ: ${TZ}
    volumes:
      - model-cache: /cache

  redis:
    name: immich_redis
    options:
      - from: ghcr.io/daemonless/redis:latest
    oci:
      environment:
        - LANG: C.UTF-8
        - TZ: ${TZ}
    volumes:
      - redis-data: /config

  database:
    name: immich_postgres
    options:
      - from: ghcr.io/daemonless/immich-postgres:latest
      - template: immich-postgres-template.conf
    oci:
      environment:
        - POSTGRES_PASSWORD: ${DB_PASSWORD}
        - POSTGRES_USER: ${DB_USERNAME}
        - POSTGRES_DB: ${DB_DATABASE_NAME}
    volumes:
      - db-data: /var/lib/postgresql/data

volumes:
  immich-data:
    device: ${UPLOAD_LOCATION}

  model-cache:
    device: /media/immich/app-jail/cache
  redis-data:
    device: /media/immich/app-jail/redis
  db-data:
    device: /media/immich/app-jail/postgres

run.sh:
Code:
#!/bin/sh
. .env
# Set required environment variables for AppJail
export DB_USERNAME DB_PASSWORD DB_DATABASE_NAME TZ \
  UPLOAD_LOCATION CACHE_LOCATION REDIS_DATA_LOCATION DB_DATA_LOCATION
# Create directories and assign ownership to UID 1000 (standard OCI non-root user)
mkdir -p "$UPLOAD_LOCATION" "$CACHE_LOCATION" "$REDIS_DATA_LOCATION" "$DB_DATA_LOCATION"
chown -R 1000:1000 /media/immich/app-jail
# Bring up the environment
appjail-director up

I am removing any env variables from appjail-directory.yml because it seems like for whatever reason, they're not being picked up. I suspect that is why provisioning is failing.
 
I removed all the vars from appjail-director.yml, but am still ending up with

Code:
./run.sh
Starting Director (project:immich) ...
Destroying database (immich_postgres) ... Done.
Creating immich-machine-learning (immich_machine_learning) ... FAIL!

I think the next steps are to add debug logging to the python scripts. There isn't much for me to see and debug.
 
add debug logging to the python scripts
Learn to use pdb. Don't have to add anything to the code itself, just python3 -m pdb mypython.py will invoke it. Set breakpoints at interesting spots, have it break, then check the contents of various variables and structures to see if it all matches up. Single step through interesting code to see if it does what it's supposed to do.
 
You don't need to use pdb, since Director isn't wrong. Director is simply indicating that a service (aka jail) is failing during the creation phase. All you need to do is check the logs generated by Director.

Code:
$ appjail-director info
immich:
  state: DONE
  last log: /home/user/.director/logs/2026-08-31_00h31m28s
  locked: false
  services:
    + immich-server (immich_server)
    + immich-machine-learning (immich_machine_learning)
    + database (immich_postgres)
    + redis (immich_redis)
$ ls /home/user/.director/logs/2026-08-31_00h31m28s
database      immich-machine-learning immich-server           redis

I am removing any env variables from appjail-directory.yml because it seems like for whatever reason, they're not being picked up. I suspect that is why provisioning is failing.

Yes, the reason is that you're missing the !ENV tag, as indicated in the README file: https://github.com/DtxdF/director#environment

See also: director(1)

And please tag me in the next case, or I won't know that you have a problem related to AppJail/Director.
 
You don't need to use pdb, since Director isn't wrong. Director is simply indicating that a service (aka jail) is failing during the creation phase. All you need to do is check the logs generated by Director.

Code:
$ appjail-director info
immich:
  state: DONE
  last log: /home/user/.director/logs/2026-08-31_00h31m28s
  locked: false
  services:
    + immich-server (immich_server)
    + immich-machine-learning (immich_machine_learning)
    + database (immich_postgres)
    + redis (immich_redis)
$ ls /home/user/.director/logs/2026-08-31_00h31m28s
database      immich-machine-learning immich-server           redis



Yes, the reason is that you're missing the !ENV tag, as indicated in the README file: https://github.com/DtxdF/director#environment

See also: director(1)

And please tag me in the next case, or I won't know that you have a problem related to AppJail/Director.

Well, this is interesting, so I think the problem might have been due to my existing media / ZFS datasets. I started with empty dirs entirely (I didn't mount my media datasets at all) and my same configuration started just fine.

The only confusing thing is that my existing configuration seems wrong as I have these dirs created:


Code:
${CACHE_LOCATION}
${UPLOAD_LOCATION}
${DB_DATA_LOCATION}
${REDIS_DATA_LOCATION}

But, it now starts fine. The media dirs, /media/immich/{cache,library,postgres,redis} were all created, but sit empty and the ones above are where everything went.
 
But, it now starts fine. The media dirs, /media/immich/{cache,library,postgres,redis} were all created, but sit empty and the ones above are where everything went.
Have you specified the !ENV tag?

Code:
...
volumes:
  immich-data:
    device: !ENV '${UPLOAD_LOCATION}'
  model-cache:
    device: !ENV '${CACHE_LOCATION}'
  redis-data:
    device: !ENV '${REDIS_DATA_LOCATION}'
  db-data:
    device: !ENV '${DB_DATA_LOCATION}'
 
But, it now starts fine. The media dirs, /media/immich/{cache,library,postgres,redis} were all created, but sit empty and the ones above are where everything went.
Ah, now I understand that previous sentence. Yes, maybe the problem is that you haven't mounted the file system where the data for immich and his friends will be stored, so it's empty.

In those cases, you can switch the volumes to a temporary directory to check if everything works properly before using them.

Before:

Code:
UPLOAD_LOCATION=/var/appjail-volumes/immich/library
DB_DATA_LOCATION=/var/appjail-volumes/immich/postgres
CACHE_LOCATION=/var/appjail-volumes/immich/cache
REDIS_DATA_LOCATION=/var/appjail-volumes/immich/redis
TZ=America/Caracas
DB_PASSWORD=postgres
DB_USERNAME=postgres
DB_DATABASE_NAME=immich
DIRECTOR_PROJECT=immich

After:

Code:
UPLOAD_LOCATION=/tmp/appjail-volumes/immich/library
DB_DATA_LOCATION=/tmp/appjail-volumes/immich/postgres
CACHE_LOCATION=/tmp/appjail-volumes/immich/cache
REDIS_DATA_LOCATION=/tmp/appjail-volumes/immich/redis
TZ=America/Caracas
DB_PASSWORD=postgres
DB_USERNAME=postgres
DB_DATABASE_NAME=immich
DIRECTOR_PROJECT=immich
 
Back
Top