Docker Compose [建議使用]
Docker Compose 是在生產環境中運行 Immich 的建議方法。以下是使用 Docker Compose 部署 Immich 的步驟。
Step 1 - Download the required files
Create a directory of your choice (e.g. ./immich-app
) to hold the docker-compose.yml
and .env
files.
mkdir ./immich-app
cd ./immich-app
Download docker-compose.yml
and example.env
by running the following commands:
wget -O docker-compose.yml https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
wget -O .env https://github.com/immich-app/immich/releases/latest/download/example.env
You can alternatively download these two files from your browser and move them to the directory that you created, in which case ensure that you rename example.env
to .env
.
Step 2 - Populate the .env file with custom values
# 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 where your database files are stored. Network shares are not supported for the database
DB_DATA_LOCATION=./postgres
# To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
# TZ=Etc/UTC
# 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
# Please use only the characters `A-Za-z0-9`, without special characters or spaces
DB_PASSWORD=postgres
# The values below this line do not need to be changed
###################################################################################
DB_USERNAME=postgres
DB_DATABASE_NAME=immich
- Populate
UPLOAD_LOCATION
with your preferred location for storing backup assets. It should be a new directory on the server with enough free space. - Consider changing
DB_PASSWORD
to a custom value. Postgres is not publicly exposed, so this password is only used for local authentication. To avoid issues with Docker parsing this value, it is best to use only the charactersA-Za-z0-9
.pwgen
is a handy utility for this. - Set your timezone by uncommenting the
TZ=
line. - Populate custom database information if necessary.
Step 3 - Start the containers
From the directory you created in Step 1 (which should now contain your customized docker-compose.yml
and .env
files), run the following command to start Immich as a background service:
docker compose up -d
如果您遇到類似 unknown shorthand flag: 'd' in -d
或 open <location of your .env file>: permission denied
的錯誤,可能是因為您運行的是錯誤的 Docker 版本。(例如,在 Ubuntu 22.04.3 LTS 中使用 docker.io 套件時會出現此情況。)您可以通過按照適用於您的發行版的完整 Docker Engine 安裝 程序來解決該問題,尤其是 "卸載舊版本" 和 "使用 apt/rpm 軟件庫安裝" 部 分。這些會將發行版的 Docker 軟件包替換為 Docker 的官方版本。
注意,正確的命令確實是 docker compose
,而不是 docker-compose
。如果您在原生的 Ubuntu 22.04 上嘗試後者,則會以另一種方式失敗:
The Compose file './docker-compose.yml' is invalid because:
'name' does not match any of the regexes: '^x-'
參閱前一段關於從官方 Docker 軟件庫安裝的說明。
如果您遇到錯誤 can't set healthcheck.start_interval as feature require Docker Engine v25 or later
,建議注釋掉 docker-compose.yml
文件中 database
部分的 start_interval
行。