Skip to main content

Environment Variables

caution

To change environment variables, you must recreate the Immich containers. Just restarting the containers does not replace the environment within the container!

In order to recreate the container using docker compose, run docker compose up -d. In most cases docker will recognize that the .env file has changed and recreate the affected containers. If this should not work, try running docker compose up -d --force-recreate.

Docker Compose

VariableDescriptionDefaultServices
IMMICH_VERSIONImage tagsreleaseserver, microservices, machine learning, web, proxy
UPLOAD_LOCATIONHost Path for uploadsserver, microservices
tip

These environment variables are used by the docker-compose.yml file and do NOT affect the containers directly.

General

VariableDescriptionDefaultServices
TZTimezonemicroservices
NODE_ENVEnvironment (production, development)productionserver, microservices, machine learning, web
LOG_LEVELLog Level (verbose, debug, log, warn, error)logserver, microservices
IMMICH_MEDIA_LOCATIONMedia Location./uploadserver, microservices
IMMICH_CONFIG_FILEPath to config fileserver, microservices
IMMICH_WEB_ROOTPath of root index.html/usr/src/app/wwwserver
IMMICH_REVERSE_GEOCODING_ROOTPath of reverse geocoding dump directory/usr/src/resourcesmicroservices
tip

TZ is only used by the exiftool as a fallback in case the timezone cannot be determined from the image metadata.

exiftool is only present in the microservices container.

Ports

VariableDescriptionDefaultServices
PORTWeb Port3000web
SERVER_PORTServer Port3001server
MICROSERVICES_PORTMicroservices Port3002microservices
MACHINE_LEARNING_HOSTMachine Learning Host0.0.0.0machine learning
MACHINE_LEARNING_PORTMachine Learning Port3003machine learning

Database

VariableDescriptionDefaultServices
DB_URLDatabase URLserver, microservices
DB_HOSTNAMEDatabase Hostlocalhostserver, microservices
DB_PORTDatabase Port5432server, microservices
DB_USERNAMEDatabase Userpostgresserver, microservices
DB_PASSWORDDatabase Passwordpostgresserver, microservices
DB_DATABASE_NAMEDatabase Nameimmichserver, microservices
DB_VECTOR_EXTENSION*1Database Vector Extension (one of [pgvector, pgvecto.rs])pgvecto.rsserver, microservices

*1: This setting cannot be changed after the server has successfully started up

info

When DB_URL is defined, the other database (DB_*) variables are ignored.

Redis

VariableDescriptionDefaultServices
REDIS_URLRedis URLserver, microservices
REDIS_HOSTNAMERedis Hostimmich_redisserver, microservices
REDIS_PORTRedis Port6379server, microservices
REDIS_DBINDEXRedis DB Index0server, microservices
REDIS_USERNAMERedis Usernameserver, microservices
REDIS_PASSWORDRedis Passwordserver, microservices
REDIS_SOCKETRedis Socketserver, microservices
info

REDIS_URL must start with ioredis:// and then include a base64 encoded JSON string for the configuration. More info can be found in the upstream ioredis documentation.

  • When REDIS_URL is defined, the other redis (REDIS_*) variables are ignored.
  • When REDIS_SOCKET is defined, the other redis (REDIS_*) variables are ignored.

Redis (Sentinel) URL example JSON before encoding:

{
"sentinels": [
{
"host": "redis-sentinel-node-0",
"port": 26379
},
{
"host": "redis-sentinel-node-1",
"port": 26379
},
{
"host": "redis-sentinel-node-2",
"port": 26379
}
],
"name": "redis-sentinel"
}

Machine Learning

VariableDescriptionDefaultServices
MACHINE_LEARNING_MODEL_TTLInactivity time (s) before a model is unloaded (disabled if <= 0)300machine learning
MACHINE_LEARNING_MODEL_TTL_POLL_SInterval (s) between checks for the model TTL (disabled if <= 0)10machine learning
MACHINE_LEARNING_CACHE_FOLDERDirectory where models are downloaded/cachemachine learning
MACHINE_LEARNING_REQUEST_THREADS*1Thread count of the request thread pool (disabled if <= 0)number of CPU coresmachine learning
MACHINE_LEARNING_MODEL_INTER_OP_THREADSNumber of parallel model operations1machine learning
MACHINE_LEARNING_MODEL_INTRA_OP_THREADSNumber of threads for each model operation2machine learning
MACHINE_LEARNING_WORKERS*2Number of worker processes to spawn1machine learning
MACHINE_LEARNING_WORKER_TIMEOUTMaximum time (s) of unresponsiveness before a worker is killed120machine learning
MACHINE_LEARNING_PRELOAD__CLIPName of a CLIP model to be preloaded and kept in cachemachine learning
MACHINE_LEARNING_PRELOAD__FACIAL_RECOGNITIONName of a facial recognition model to be preloaded and kept in cachemachine learning

*1: It is recommended to begin with this parameter when changing the concurrency levels of the machine learning service and then tune the other ones.

*2: Since each process duplicates models in memory, changing this is not recommended unless you have abundant memory to go around.

info

Other machine learning parameters can be tuned from the admin UI.

Docker Secrets

The following variables support the use of Docker secrets for additional security.

To use any of these, replace the regular environment variable with the equivalent _FILE environment variable. The value of the _FILE variable should be set to the path of a file containing the variable value.

Regular VariableEquivalent Docker Secrets '_FILE' Variable
DB_HOSTNAMEDB_HOSTNAME_FILE*1
DB_DATABASE_NAMEDB_DATABASE_NAME_FILE*1
DB_USERNAMEDB_USERNAME_FILE*1
DB_PASSWORDDB_PASSWORD_FILE*1
REDIS_PASSWORDREDIS_PASSWORD_FILE*2

*1: See the official documentation for details on how to use Docker Secrets in the Postgres image.

*2: See this comment for an example of how to use use a Docker secret for the password in the Redis container.