QNAP: Running Immich using Container Station

QNAP is one of the leading companies which provide Network Attached Storage devices and for the right reasons it is also one of the favorites of the self-hosting community. Although the company advertises the device as a NAS, it is capable of much more.

Container Station provided by the QNAP app store is one of the easiest ways to host docker application on the Qnap devices. It is simple to host docker containers as well as stacks on the device. For a docker stack you just have to do the following:

Container Station > Application > Create

One such application that you might want to run on the device is Immich, a community based photo management application which you can host on your device instead of using google photos to store your pictures. The following is a sample docker-compose which you can use host the application.

version: '3.8'

name: immich

services:
  immich-redis:
    container_name: immich-redis
    image: redis:7-alpine
    volumes:
      - broker:/data
    healthcheck:
      test: redis-cli ping || exit 1
    networks:
      - immichnet
    restart: unless-stopped
    
  immich-postgres:
    container_name: immich-postgres
    image: tensorchord/pgvecto-rs:pg15-v0.2.0
    environment:
       POSTGRES_PASSWORD: <password>
       POSTGRES_USER: <username>
       POSTGRES_DB: immich
       POSTGRES_INITDB_ARGS: '--data-checksums'
       REDIS_HOSTNAME: immich-redis
       REDIS_PORT: 6379
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: pg_isready --dbname='immich' --username='postgres' || exit 1; Chksum="$$(psql --dbname='immich' --username='postgres' --tuples-only --no-align --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database')"; echo "checksum failure count is $$Chksum"; [ "$$Chksum" = '0' ] || exit 1
      interval: 5m
      start_period: 5m
    #command: ["postgres", "-c" ,"shared_preload_libraries=vectors.so", "-c", 'search_path="$$user", public, vectors', "-c", "logging_collector=on", "-c", "max_wal_size=2GB", "-c", "shared_buffers=512MB", "-c", "wal_compression=on"]
    networks:
      - immichnet
    restart: unless-stopped
    
  immich-machine-learning:
    container_name: immich-machine-learning
    # For hardware acceleration, add one of -[armnn, cuda, openvino] to the image tag.
    # Example tag: release-cuda
    image: altran1502/immich-machine-learning:release
    # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration
    #   file: hwaccel.ml.yml
    #   service: cpu # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference - use the `-wsl` version for WSL2 where applicable
    environment:
       DB_HOSTNAME: immich-postgres
       DB_DATABASE_NAME: immich
       DB_USERNAME: <username>
       DB_PASSWORD: <password>
       REDIS_HOSTNAME: immich-redis
       REDIS_PORT: 6379
    volumes:
      - model_cache:/cache
    networks:
      - immichnet
    restart: unless-stopped
    
  immich-server:
    container_name: immich-server
    image: altran1502/immich-server:release
    environment:
       DB_HOSTNAME: immich-postgres
       DB_DATABASE_NAME: immich
       DB_USERNAME: <username>
       DB_PASSWORD: <password>
       MACHINE_LEARNING_WORKER_TIMEOUT: 600
       REDIS_HOSTNAME: immich-redis
       REDIS_PORT: 6379
    volumes:
      - /share/CACHEDEV2_DATA/Photos:/usr/src/app/upload    <-- Something you might need to update
      - /etc/localtime:/etc/localtime:ro
    ports:
      - 2283:2283
    depends_on:
      - immich-redis
      - immich-postgres
      - immich-machine-learning
    networks:
      - immichnet
    restart: unless-stopped

volumes:
    broker:
    pgdata:
    model_cache:

networks:
    immichnet:
        name: immichnet    
        driver: bridge

You will require to change the following things in the above file:

  • database username (marked in bold)
  • database password (marked in bold)
  • volumes for immich-server: the mount volume marked in italic should be the location of the storage folder in your QNAP device

Leave a Comment