Immich in Docker
Immich (github) is a media library tool.
At some point I’ve lost my QNAP drives (both at the almost the same time) and wanted to check if I could replace the PhotoStation with an opensource tool.
Immich was one of the candidates but if has a major drawback for me. I dislike that it renames the files you upload/import/sync with it. Although it allows you to download them and the metadata it keeps (in a database) contain all the info and the result you get is the original filenames, you cannot suddenly stop using it and pick the file structure and use it. If you lose the database you have to manually rename and organize all files which can be practically impossible if you have several thousand images or videos in your library.
Still I wanted to try it so lets get into this.
- First of all you need to decide where to store its configuration files and docker compose yaml.
setup location
mkdir ~/immich
- configure the variables that immich need to start (read examples and config notes in immich site)
configure
Set your variable in a .env file like this:
# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables
# The location where your uploaded files are stored
UPLOAD_LOCATION=./library
# The location of an external library
EXTERNAL_PATH=/home/me/immich/workdir
# 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=sample-password
TYPESENSE_API_KEY=the_typeSense_key
# 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
- finaly the docker compose file (which is slightly updated since I’m currently playing with traefik)
docker compose
#
# 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']
labels:
- "traefik.enable=true"
- "traefik.http.routers.immich-server.rule=PathPrefix(`/immich`) || Host(`immich.docker.localhost`))"
- "traefik.http.routers.immich-server.tls=true"
- "traefik.docker.network=traefik_default"
volumes:
- ${UPLOAD_LOCATION}:/usr/src/app/upload
- /etc/localtime:/etc/localtime:ro
- ${EXTERNAL_PATH}:/usr/src/app/external
env_file:
- .env
ports:
- 2283:3001
depends_on:
- redis
- database
restart: always
networks:
- default
- traefik_default
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
- ${EXTERNAL_PATH}:/usr/src/app/external
env_file:
- .env
depends_on:
- redis
- database
restart: always
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
redis:
container_name: immich_redis
image: registry.hub.docker.com/library/redis:6.2-alpine@sha256:51d6c56749a4243096327e3fb964a48ed92254357108449cb6e23999c37773c5
restart: always
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
volumes:
pgdata:
model-cache:
networks:
traefik_default:
external: true
name: traefik_default
default:
Of course this means this particular docker compose depends on an existing running traefik
Also it is important to check the related host line and adapt accordingly (like adding extra Host domain)
- "traefik.http.routers.immich-server.rule=PathPrefix(`/immich`) || Host(`immich.docker.localhost`))"
upgrading it
And so you have it running, but immich is under heavy development as noted in the site and as a result it keeps changing quite often.
it is really important that you check the release notes for breaking changes and incompatibilities with the mobile app you might have, before you initiate the simple upgrade process below.
- Get in the immich directory where the docker compose file is stored and do a
docker compose pull - when everything is pulled do a
docker compose up --force-recreate --build -dwill restart it to the latest version
important note : If you don’t change the docker compose file, you will only be pulling the immich updates, since the rest of the services (redis, postgresql) have their version pinned.