
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
This is one way syncing solution so we need source and destination implementation.
lsync,ssh-client,rsyncrsyncBooth images aditionaly contains packages net-tools, tree, vim for easer debuging during trouble shooting. Because services need to be high available.
See documentation of base image https://hub.docker.com/r/linuxserver/openssh-server.%5C Plus you can:
Instead of using enviroment properties PUBLIC_KEY and PUBLIC_KEY_FILE use rather AUTHORIZED_KEYS and AUTHORIZED_KEYS_FILE.
This properties correctly merge multiple keys (seppareted by new line) to authorized_keys.
Plus authorized_key can be updated without reboot by command:
bashdocker exec $container merge-audthorized_keys
You can use ssh-entrypoint.sh as command for authorized keys which set default working directory to /data for all ssh connections (works also with lsync, scp, etc.).
Usage:
bash-e AUTHORIZED_KEYS='command="ssh-entrypoint.sh \"${SSH_ORIGINAL_COMMAND:-bash -l}\"" ssh-rsa AAAAXY...Z== comment'
Image uses lsyncd preconfiured by docker-entrypoint.sh.
Configuration consist of two steps:
~/.ssh/config like:
SSHHost $TARGET_HOST User $TARGET_USER Port $TARGET_SSH_PORT IdentityFile $SSH_KEY_FILE CheckHostIP no
SSH_KEY is provided, its contnet is automaticaly strored to file and name of file in SSH_KEY_FILE~/.ssh/known_hosts is automaticlaly created using HOST_KEY or at startup.ssh hostname inside container.~/lsyncd.conf.lua like:
Luasettings { statusFile = "$HOME/lsyncd.status", nodaemon = true, insist = true, inotifyMode = "${INOTIFY_MODE:-CloseWrite}", } sync { default.rsyncssh, source = "$SOURCE_PATH:-/var/source", -- source path inside container host = "$TARGET_HOST", targetdir = "$TARGET_PATH", -- path at remote ssh server delay = ${SYNC_DELAY:-0}, excludeFrom = "$HOME/lsyncd.excludes", -- file automaticaly created from env EXCLUDES delete = "${DELETE:-running}", -- IMPORTAT rsync = { archive = ${RSYNC_ARCHIVE:-true}, compress = ${RSYNC_COMPRESS:-false}, } }
sync.delete must by set to running (or false) if multiple sources are synchronized to same target.sync.delay allow pospond synchronization n seconds, which optimize synchronization process by invoking rsync less frequent.| Property | Type | Default Value | Description |
|---|---|---|---|
| INOTIFY_MODE | enum | CloseWrite | "Modify", "CloseWrite" or "CloseWrite or Modify" |
| SOURCE_PATH | dir | /var/source | where source direcory is mounted, can be read-only |
| SYNC_DELAY | number | 0 | seconds |
| EXCLUDES | pattern | *~ | rsync patterns separated by newline |
| DELETE | enum | running | true, false, startup or running |
| RSYNC_ARCHIVE | boolean | true | |
| RSYNC_COMPRESS | boolean | true | |
| TARGET_USER | string | required | |
| TARGET_HOST | hostname | required | |
| TARGET_SSH_PORT | number | 22 | |
| TARGET_PATH | path | required | |
| SSH_KEY | string | required if not SSH_KEY_FILE (SSH_KEY has precedence) | |
| SSH_KEY_FILE | path | required if not SSH_KEY, identity file mounted to container | |
| HOST_KEY | string | optional, ecdsa-sha2 public key of remote host (used in known_hosts) |
install-lsyncdThis script allows easy to setup client service running from docker.
Just go to dicrectory wich sould be synchronized and launch command:
shinstall-lsyncd user@host:port:/target/dir -i /path/to/id_rsa --delay=2
LASTEST="$(curl -sI https://github.com/solargis/docker-lsyncd/releases/latest | perl -ne '/^Location: .*\/releases\/tag\/(\S+)/i && print $1')"; sudo curl -Ls https://github.com/solargis/docker-lsyncd/releases/download/$LASTEST/install-lsyncd -o /usr/local/bin/install-lsyncd && sudo chmod +x /usr/local/bin/install-lsyncd
For testing use ./demo.sh which prepares environment and start docker-compose.
Containners in docker-compose.yml works according to this schema:
!diagram
Usage:
./demo.sh setup - prepare envinoment source and target directories, client and host keys, .env file./demo.sh start - call ./demo.sh setup and then start containers by docker-compose up./demo.sh watch - call ./demo.sh start and then start watching source and target directories./demo.sh stop - destory containers by docker-compose down./demo.sh cleanup - call ./demo.sh stop and then remove keys, source and target directoriesNote:
Sometimes, after fresh creation of bind directories, the changes are not reflected inside conainer .
If synchronization not works, you can quickly chcek if local files match containers files by executing: ./demo.sh check.
If not, then you simply creacreate containers by ./demo.sh stop && ./demo.sh stop.
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务