【笔记】通过Docker部署Immich

前言

通过Docker部署Immich

通过DockerCompose部署

下载DockerCompose文件

1
wget -O docker-compose.yml https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml

修改DockerCompose文件

  • 为了防止无法读取系统的localtime的文件,把`- /etc/localtime:/etc/localtime:ro`注释
  • 为了防止从registry.hub.docker.com下载镜像出错,更换redis镜像的下载源为redis:6.2-alpine,更换postgres镜像的下载源为tensorchord/pgvecto-rs:pg14-v0.2.0
  • 为了防止权限报错,为每个容器开启特权模式privileged: true
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#
# 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: unless-stopped
privileged: true

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: unless-stopped
privileged: true

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
depends_on:
- redis
- database
restart: unless-stopped
privileged: true

redis:
container_name: immich-redis
# image: registry.hub.docker.com/library/redis:6.2-alpine@sha256:84882e87b54734154586e5f8abd4dce69fe7311315e2fc6d67c29614c8de2672
image: redis:6.2-alpine
restart: unless-stopped
privileged: true

database:
container_name: immich-postgres
# image: registry.hub.docker.com/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
image: tensorchord/pgvecto-rs:pg14-v0.2.0
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_DB: ${DB_DATABASE_NAME}
volumes:
- ${DB_DATA_LOCATION}:/var/lib/postgresql/data
restart: unless-stopped
privileged: true

volumes:
model-cache:

下载.env配置文件

1
wget -O .env https://github.com/immich-app/immich/releases/latest/download/example.env

修改.env配置文件

UPLOAD_LOCATION:定义照片存放路径 DB_DATA_LOCATION:定义数据库文件存放路径 DB_PASSWORD:定义数据库用户密码 DB_USERNAME:定义数据库用户名 DB_DATABASE_NAME:定义数据库名

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 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=/root/Pictures
# The location where your database files are stored
DB_DATA_LOCATION=/root/postgres

# 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=postgres

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

通过DockerCompose启动容器

1
docker compose up -d

初始化

  • 注册账户->Sign up

  • 使用刚才注册的账户登录->Login

  • Theme

  • 选择一个主题->Storage Template

  • Done

创建其他用户

  • Administrator->Creste user

  • 设置新用户信息->Creste

移动端登录

服务器地址:http://192.168.0.1:2283/api 邮箱:注册时的邮箱 密码:注册时的密码

完成

  • 截图纪念

参考文献

Immich官方文档 知乎——沉重的心雨