HOW TO: Install Immich server on a Raspberry Pi using Docker.

  • Post last modified:April 2, 2024
  • Reading time:10 mins read
  • Post comments:4 Comments

How to: Install and run Immich on RPI using Docker.

What is Immich? https://immich.app/

Immich is an innovative photo management platform that serves as a viable alternative to Google Photos. It leverages advanced machine learning algorithms to organize your photos in an intuitive and efficient manner.

With Immich, you can effortlessly store, manage, and access your photos from anywhere at any time. Its machine learning capabilities enable it to recognize patterns, categorize photos, and even identify individuals or objects within the images. This makes searching for specific photos or sets of photos incredibly easy and quick.

In addition to its powerful photo organization features, Immich also offers robust privacy and security measures to ensure your photos are kept safe and secure. With its user-friendly interface and intelligent features, Immich is not just a replacement for Google Photos, but a significant upgrade. Whether you’re a professional photographer or someone who simply loves capturing moments, Immich offers a seamless and enriched photo management experience.

 


 

What you will need:

  • Raspberry Pi 4 or 5 (Minimum 4gb. Immich recommends using 6gb) Do Not Use a SD Card
  • Static IP address
  • Docker/Docker-compose installed. If you don’t have it, checkout the guide:linuxpi.ca/how-to-install-docker-on-a-raspberry-pi/
  • External storage, the larger, the better. (Can be an old HDD, it doesn’t need to be fast.) preferably formatted GPT, ext4.

 

Setup: (Create directory and mount storage drive)

 

Step 1: Create Directory and give premission:

 

First we are going to create a directory to mount and store our Immich media content too. Go to your root directory, and make a new directory called immich:

cd /
sudo mkdir immich

 

Give premission:

sudo chown -R 1000:1000 /immich

 

Step 2: Mount storage Drive:

Next we need to mount the storage drive to the immich directory. (If not using secondary/external drive skip this step).

 

We need to find the drive letter of the storage drive:

sudo lsblk

You should get a list like this:

NAME       MAJ:MIN RM  SIZE   RO TYPE  MOUNTPOINTS
sda         8:0    0   1.8T   0  disk
└─sda1      8:1    0   1.8T   0  part
sdb         8:16   0   21.8T  0  disk
└─sdb1      8:17   0   21.8T  0  part  /media
zram0       253:0  0   512M   0  disk  [SWAP]
nvme0n1     259:0  0   238.5G 0  disk
├─nvme0n1p1 259:1  0   512M   0  part  /boot/firmware
└─nvme0n1p2 259:2  0   238G   0  part  /

I’ll be using the 1.8T drive partition: sda1. (Yours may be different)

 

We need to find the PARTUUID number for the storage drive sda1:

sudo blkid

 

You will see another list of the same drives, but with different information:

/dev/nvme0n1p1: LABEL_FATBOOT="bootfs" LABEL="bootfs" UUID="5DF9-E225" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="41235e93-01"
/dev/nvme0n1p2: LABEL="rootfs" UUID="3b614a3f-4a65-4480-876a-8a998e01ac9b" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="41235e93-02"
/dev/sda1: LABEL=”immich” UUID=”97d9a5ed-c153-4eb2-9a8f-f262137178ce” BLOCK_SIZE=”4096″ TYPE=”ext4″ PARTLABEL=”immich” PARTUUID=”ed6f0ed7-52e9-4714-91c6-bee28995ede5″
/dev/sdb1: LABEL="Plex" UUID="8f3ed53a-4b6b-41cf-9dd3-93f23276599c" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="495b1d51-62fb-45a7-b7ee-9582647ca8d6"

 

In this case the PARTUUID=”ed6f0ed7-52e9-4714-91c6-bee28995ede5″. (Yours will be different)

 

Now we have to edit fstab to permanently mount the storage drive to the /immich directory:

sudo nano /etc/fstab

 

At the bottom of the file add:

PARTUUID=Your-Drives-PARTUUID /immich ext4 nosuid,nodev,nofail 0    1 ### Remember to add your drives specific PARTUUID.

Remember to add your drives specific PARTUUID.

 

Now save (Ctrl+s) and Exit (Ctrl+x)

 

Your drive will now permanently be mounted to the /immich directory on reboot. instead of rebooting we can just manually mount the drive ourselves:

sudo mount /dev/sda1 /immich ### Remember to use your own drive letters sda1,sdb1 etc..

 

To check if the drive was mounted:

sudo lsblk

NAME       MAJ:MIN RM  SIZE   RO TYPE  MOUNTPOINTS
sda         8:0    0   1.8T    0 disk
└─sda1      8:1    0   1.8T    0 part /immich

 

You will now see /immich under mount points for your storage drive.


 

Install: Create and run docker-compose.yml, and .env files, to install Immich.

 

Step 1: Making a Docker directory for Immich and give permission:

Create a new directory in your root Docker directory. (If you followed the guide then the root would be /home/USERNAME/docker)

cd ~/docker ### ~/ is a shortcut to your /home/USERNAME directory
sudo mkdir ~/docker/immich

 

Enter the new Immich directory

cd ~/docker/immich

 

Give premission:

sudo chown -R 1000:1000 ./

 

Step 2: Create a .env file to hide sensitive information:

sudo nano .env

 

Copy:

# The location where your uploaded files are stored
UPLOAD_LOCATION=/immich

# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release

# Connection secret for postgres. You should change it to a random password
DB_PASSWORD=PASSWORD

# The values below this line do not need to be changed
######################################################
DB_HOSTNAME=immich_postgres
DB_USERNAME=postgres
DB_DATABASE_NAME=immich

REDIS_HOSTNAME=immich_redis

 

Paste into the .env file (Shift+Ctrl+v)

 

Change the DB_PASSWORD

 

Save (Ctrl+s) and Exit (Ctrl+x)

 

Step 3: Create a docker-compose.yml file.

 

We use this file to setup and run the Immich server:

sudo nano docker-compose.yml

 

It is recommended to download the lastest docker-compose.yml from here

OR

Use our version with a network for immich added. docker-compose.yml
#
# WARNING: Make sure to use the docker-compose.yml of the current release:
#
# https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
#
# The compose file on main may not be compatible with the latest release.
#


name: immich

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: ['start.sh', 'immich']
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - 2283:3001
    depends_on:
      - redis
      - database
    restart: always
    networks:
      - immich-network

  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/hardware-transcoding
    #   file: hwaccel.transcoding.yml
    #   service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
    command: ['start.sh', 'microservices']
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    depends_on:
      - redis
      - database
    restart: always
    networks:
      - immich-network

  immich-machine-learning:
    container_name: immich_machine_learning
    # For hardware acceleration, add one of -[armnn, cuda, openvino] to the image tag.
    # Example tag: ${IMMICH_VERSION:-release}-cuda
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-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
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always
    networks:
      - immich-network

  redis:
    container_name: immich_redis
    image: registry.hub.docker.com/library/redis:6.2-alpine@sha256:51d6c56749a4243096327e3fb964a48ed92254357108449cb6e23999c37773c5
    restart: always
    networks:
      - immich-network

  database:
    container_name: immich_postgres
    image: registry.hub.docker.com/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: always
    networks:
      - immich-network

volumes:
  pgdata:
  model-cache:

networks:
  immich-network: 
    driver: bridge

 

Paste into the docker-compose.yml file (Shift+Ctrl+v)

 

Save (Ctrl+s) and Exit (Ctrl+x)

 

Step 4: Run docker-compose.yml

 

Running the docker-compose.yml (we just made) will automatically:

  • Download/Pull the image files needed to install and run the Immich server.
  • Create the nessesary directories for the data base, and machine learning.
  • Creat the Immich network within Docker for Immich services to communicate. (Immich server, Immich Microservices, Machine learning, Redis (database), and Postgres (database).
  • Start the Server.

 

To run type:

sudo docker-compose up -d

 

That’s all, Immich should now be up and running!

To Access Immich, open a web browser, and type:

http://Your-IP:2283. Example: http://192.168.0.133:2283

 

To manage the Docker Immich stack use Portainer, Guide found Here.

If you need any more information for Immich there’s more documentation here: https://immich.app/docs/overview/introduction

This Post Has 4 Comments

  1. gv

    great install guide thank you so much. the docker run script has now changed to …sudo docker compose up -d
    a hyphen is not required between “docker” and “compose” for the latest version.

    1. NolandC

      Yes you are correct, with compose v2 the hyphen is no longer required. Thank you, I will make sure to update.

  2. xm

    thanks you. it helped.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.