NAS and server panels
Deploy ImgYoung with one compose file on Synology, 1Panel, BT Panel, CasaOS, Unraid and similar systems with a graphical interface, and handle data directory permissions.
These systems all run Docker images. ImgYoung on them is the same program as on a plain host; only the place where you create the container is a graphical interface. Below is one generic compose file, followed by the entry point and caveats for each system.
The generic compose file
# ImgYoung 的 Docker Compose 示例:数据放在宿主机目录,适合群晖、1Panel、宝塔、CasaOS 等带图形界面的系统。
# 用法:改下面标了「改」的两处,粘贴进系统的 Compose 编辑器后启动,浏览器打开 http://<设备地址>:8721/,
# 用 admin 和容器日志里打印的初始密码登录(首次登录强制改密)。
services:
imgyoung:
image: haose/imgyoung:latest # 生产环境建议固定主次版本(如 0.1)或具体版本
# 后台「从快照恢复」会让服务优雅退出,靠重启策略重新拉起后换入快照;正常退出也要拉起
restart: unless-stopped
# 优雅停机最多约 8 秒,15 秒留有余量
stop_grace_period: 15s
# 改:以拥有数据目录的用户运行,取值为该用户的 uid:gid。镜像默认以 uid 65532 运行,
# 数据目录的属主不是它时进程无法创建数据库;进程不依赖特定 uid,只要求对 /data 可读写
user: "1000:1000"
ports:
- "8721:8721"
volumes:
# 改:换成你的数据目录。数据库、本地存储渠道与自动生成的 master.key 都在这里;
# 丢了 master.key,渠道凭证与加密数据不可恢复
- /path/to/imgyoung:/data
# environment:
# # 管理员 admin 的初始密码,至少 8 个字符;不设置时首次启动随机生成并打印在日志里
# IMGYOUNG_ADMIN_PASSWORD: 换成你的初始密码
# # 前面有反向代理时(含系统自带的网站或反向代理功能),ImgYoung 看到的对端是 Docker 网络里的地址,
# # 填该网络的网段(docker network inspect 查看);否则登录限速与 /metrics 放行会把所有请求都当成来自代理本身
# IMGYOUNG_TRUSTED_PROXIES: 172.16.0.0/12
The two places marked 「改」 ("change") must be edited: the data directory path, and the uid and gid in user:; the next section explains them. The commented-out environment variables are optional.
After it starts, open http://<device address>:8721/ and sign in as admin with the initial password; the first sign-in forces a password change. The initial password is printed in the first start's log; look for 「初始密码」 on the system's container log page.
Data directory permissions
The image runs as uid 65532 by default. When the data directory is owned by someone else, the process cannot create the database in it and fails to start.
On a NAS, shared folders usually belong to your own sign-in user, and changing the owner is awkward. ImgYoung does not depend on a particular uid; it only needs read and write access to /data, so there are two ways:
- Add
user:(recommended): set it to the uid and gid of the user that owns the data directory. The process then runs as that user, and the files in the data directory belong to that user. Sign in over SSH and runid <username>to find both numbers. - Change the owner: set the data directory's owner to
65532:65532and leave outuser:.
On systems that only accept a named volume and not a host directory, there is nothing to handle: the first mount of a named volume inherits the owner of /data in the image.
Back up master.key separately
Channel credentials and the data in encrypted channels need the master key to decrypt. It lives in master.key in the data directory and is not part of the metadata database snapshot. Copy it somewhere else after the first start; see the "The data volume" section of Docker image.
Synology Container Manager
Container Manager on DSM 7.2 and later (the package name differs slightly between DSM versions):
- Under "Project", click "Create", choose to create the compose file in the editor as the source, and paste in the content above.
- Installing Container Manager creates a shared folder named
docker. Put the data directory under it, for example/volume1/docker/imgyoung; this is the path on the left of the colon undervolumes:. - For the uid and gid in
user:, runidfor your sign-in user.
1Panel
Create it under "Container", "Compose". 1Panel offers three ways: edit in the web editor, pick an existing docker-compose.yml on the server, or use a compose template. Choose edit and paste the content above.
If you use 1Panel's website feature as the reverse proxy, see "Behind a reverse proxy" below.
BT Panel
Create a new project under "Container orchestration" in the Docker module, using the compose file above.
If you use BT Panel's website feature as the reverse proxy, see "Behind a reverse proxy" below.
CasaOS and ZimaOS
Click "+" beside the apps area on the dashboard, choose custom install, and paste the compose file above through the import function; CasaOS converts it into its own app format. Check for host port conflicts before installing: if 8721 is taken, the install can fail without an error. Change the number on the left of the colon under ports: to a free port.
Unraid
Unraid's built-in way is to fill in "Add Container" item by item: the image is haose/imgyoung, the container port is 8721, and add one path mapping with /data as the container path and a location in your array share as the host path. You can also install a plugin such as Compose Manager Plus from Community Applications and use the compose file above directly. Either way the data directory must be writable by the process; see "Data directory permissions" above.
Other systems
Any system that runs Docker images and lets you set the image, the port and the data directory mapping can deploy it: image haose/imgyoung, port 8721, and the data directory mapped to /data in the container. Where there is a Compose entry, use the file above directly.
Behind a reverse proxy
A website or reverse proxy feature built into the system usually runs on the host and forwards through the published port, so ImgYoung sees the Docker bridge gateway as the peer, not the loopback address. Set the network the proxy is on as trusted; otherwise the login rate limit treats all visitors as one source, and the image links it returns start with http://. See Docker image for how, and Reverse proxy for the proxy's own configuration.
Upgrading
The latest tag does not update itself. To upgrade, click "Back up now" under "Settings → Backups & export" in the admin UI, then pull the new image and recreate the container in the system's interface; the buttons differ by system. The data is in the data directory and survives recreating the container. See Upgrade for rollback and caveats.