Post

Take Control of Your Photos – Self-Host Immich on Your Server

Protect your personal photos and videos by hosting them yourself. In this video, you’ll learn how to install Immich, an open-source photo and video platform, on your own home server using Docker. Take control of your data with a fast, modern interface, GPU-accelerated features, and the ability to use your own NAS or network storage.

📺 Watch Video

Info

To to learn more about immich, check out the GitHub repo

Install Docker

To install docker, see this post

GPU

check for card

1
lspci

Supported NVIDIA cards (5.2 CUDA and higher)

list all drivers

1
ubuntu-drivers devices

install recommended nvidia drivers

1
sudo ubuntu-drivers install

reboot

1
sudo reboot

check to see if drivers are installed and working

1
nvidia-smi

NVIDIA Container Toolkit

https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html

Configure the production repository:

1
2
3
4
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
  && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
    sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
    sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

update packages

1
sudo apt-get update

Install NVIDIA Container Toolkit packages

1
2
3
4
5
6
export NVIDIA_CONTAINER_TOOLKIT_VERSION=1.17.8-1
  sudo apt-get install -y \
      nvidia-container-toolkit=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
      nvidia-container-toolkit-base=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
      libnvidia-container-tools=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
      libnvidia-container1=${NVIDIA_CONTAINER_TOOLKIT_VERSION}

Configure docker to run the toolkit

1
sudo nvidia-ctk runtime configure --runtime=docker

restart docker

1
sudo systemctl restart docker

run nvidia smi inside the ubuntu container

1
docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi

Configure

create folders for our stack

1
sudo mkdir -p /opt/stacks/immich

change ownership of the folder (change group:user)

1
sudo chown serveradmin:serveradmin -R /opt/stacks

change directories

1
cd /opt/stacks/immich

create our compose file

1
nano compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: immich

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    extends:
      file: hwaccel.transcoding.yml
      service: ${TRANSCODING_BACKEND:-cpu}
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    #   - /mnt/photos:/mnt/photos:ro # update and uncomment if you are using a network share
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - '2283:2283'
    depends_on:
      - redis
      - database
    restart: always
    healthcheck:
      disable: false
    # labels:
      # - "traefik.enable=true"
      # - "traefik.http.routers.${TRAEFIK_ROUTER_NAME}.rule=Host(`${TRAEFIK_DOMAIN}`)"
      # - "traefik.http.routers.${TRAEFIK_ROUTER_NAME}.entrypoints=websecure"
      # - "traefik.http.routers.${TRAEFIK_ROUTER_NAME}.tls.certresolver=${TRAEFIK_CERT_RESOLVER}"
      # - "traefik.http.services.${TRAEFIK_ROUTER_NAME}.loadbalancer.server.port=2283"

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}-cuda
    extends:
      file: hwaccel.ml.yml
      service: cuda
    volumes:
      - model-cache:/cache 
    env_file:
      - .env
    restart: always
    healthcheck:
      disable: false

  redis:
    container_name: immich_redis
    image: docker.io/valkey/valkey:8-bookworm
    healthcheck:
      test: redis-cli ping || exit 1
    restart: always

  database:
    container_name: immich_postgres
    image: ghcr.io/immich-app/postgres:14-vectorchord0.3.0-pgvectors0.2.0
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_INITDB_ARGS: '--data-checksums'
      DB_STORAGE_TYPE: ${DB_STORAGE_TYPE:-SSD}
    volumes:
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
    env_file:
      - .env
    restart: always

volumes:
  model-cache:
1
nano hwaccel.ml.yml
1
2
3
4
5
6
7
8
9
10
services:
  cuda:
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities:
                - gpu
1
nano hwaccel.transcoding.yml
1
2
3
4
5
6
7
8
9
10
11
12
services:
  nvenc:
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities:
                - gpu
                - compute
                - video
1
nano .env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Required paths
UPLOAD_LOCATION=./library
DB_DATA_LOCATION=./postgres

# Optional timezone (not needed if localtime is mounted)
# TZ=Etc/UTC

# Version control
IMMICH_VERSION=release

# Postgres authentication
DB_PASSWORD=postgres
DB_USERNAME=postgres
DB_DATABASE_NAME=immich

# Optional tuning
DB_STORAGE_TYPE=SSD

# transcoding
TRANSCODING_BACKEND=nvenc

# traefik
TRAEFIK_ROUTER_NAME=immich
TRAEFIK_DOMAIN=immich.example.com
TRAEFIK_CERT_RESOLVER=myresolver

SMB Share

make creds dir

1
 sudo mkdir -p /etc/smb-credentials

create credentials file

1
sudo nano /etc/smb-credentials/photos

add contents (update with your username and password that has access to your share)

1
2
username=photosuser
password=Ph0t0sUs3r!

update permissions for file

1
2
sudo chmod 600 /etc/smb-credentials/photos
sudo chown root:root /etc/smb-credentials/photos

check permissions

1
 ls -l /etc/smb-credentials/photos

update fstab

1
sudo nano /etc/fstab

add mount path

1
//192.168.10.10/photos /mnt/photos cifs credentials=/etc/smb-credentials/photos,iocharset=utf8,vers=3.0,ro,nofail 0 0

install additional packages for cifs

1
sudo apt update && sudo apt install cifs-utils

reboot (mandatory)

1
sudo reboot

After rebooting you should see your share mounted at /mnt/photos

Starting container

start docker stack

1
2
cd /opt/stacks/immich
docker compose up -d

check docker containers

1
docker ps

visit server (update with your server’s IP)

More info

immich back up docs

Join the conversation

🛍️ Check out the new Merch Shop at https://l.technotim.live/shop

⚙️ See all the hardware I recommend at https://l.technotim.live/gear

🚀 Don’t forget to check out the 🚀Launchpad repo with all of the quick start source files

🤝 Support me and help keep this site ad-free!

This post is licensed under CC BY 4.0 by the author.