
如果你使用 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 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
一个简单的Go应用程序,用于测试端口是否准备好接受连接,或检查MySQL、PostgreSQL、MongoDB、Redis等服务是否就绪。还可进行HTTP调用并检查响应码和响应文本,支持超时设置,可在等待特定时间后失败。
可下载最新https://github.com/ph4r5h4d/wait4it/releases%EF%BC%8C%E6%88%96%E8%87%AA%E8%A1%8C%E6%9E%84%E5%BB%BA%E3%80%82%E6%9E%84%E5%BB%BA%E5%91%BD%E4%BB%A4%EF%BC%9A%60go build`
支持以下环境变量:
W4IT_TYPE:检查类型(http, tcp, mysql, postgres等)W4IT_TIMEOUT:超时时间(秒)W4IT_HOST:目标主机W4IT_PORT:目标端口W4IT_USERNAME:服务认证用户名W4IT_PASSWORD:服务认证密码W4IT_DBNAME:MySQL/PostgreSQL数据库名W4IT_SSL_MODE:PostgreSQL SSL模式(disable/enable)W4IT_OPERATION_MODE:Redis操作模式(standalone/cluster)W4IT_HTTP_STATUS_CODE:HTTP检查期望状态码W4IT_HTTP_TEXT:HTTP响应中需包含的子字符串W4IT_HTTP_FOLLOW_REDIRECT:HTTP是否跟随重定向(true/false,默认true)支持以下命令行标志:
-type:检查类型(http, tcp, mysql, postgres等)-h:目标主机(默认127.0.0.1)-p:目标端口-t:超时时间(秒,默认30)-u:服务认证用户名-P:服务认证密码-n:MySQL/PostgreSQL数据库名-ssl:PostgreSQL SSL模式(disable/enable)-operation-mode:Redis操作模式(standalone/cluster)-http-status:HTTP检查期望状态码-http-text:HTTP响应中需包含的子字符串-http-follow-redirect:HTTP是否跟随重定向(true/false,默认true)检查TCP端口
bash./wait4it -type=tcp -h=127.0.0.1 -p=8080 -t=60
检查MySQL实例
bash./wait4it -type=mysql -h=127.0.0.1 -p=3306 -t=60 -u=root -P=secret -n=app
检查PostgreSQL实例
bash./wait4it -type=postgres -h=127.0.0.1 -p=5432 -t=60 -u=postgres -P=secret -ssl=disable
检查HTTP响应和文本
bash./wait4it -type=http -h=https://farshad.nematdoust.com -t=60 -http-status=200 -http-text="Software Engineer" ./wait4it -type=http -h=https://nematdoust.com -t=60 -http-status=301 -http-follow-redirect=false
检查MongoDB实例
bash./wait4it -type=mongo -p=27017 -t=60 -u=mongoadmin -P=secret -h=127.0.0.1
检查Redis实例
bash# 带密码的Redis ./wait4it -type=redis -p=6379 -t=60 -P=secret -h=127.0.0.1 # 无密码的Redis ./wait4it -type=redis -p=6379 -t=60 -h=127.0.0.1 # Redis集群 ./wait4it -type=redis -p=6379 -t=60 -P=secret -operation-mode=cluster -h=127.0.0.1
检查其他服务
bash# RabbitMQ ./wait4it -type=rabbitmq -p=5267 -t=60 -u=guest -P=guest -h=127.0.0.1 # Memcached ./wait4it -type=memcached -h=127.0.0.1 -p=11211 -t=60 # ElasticSearch ./wait4it -type=elasticsearch -h=http://127.0.0.1 -p=9200 -t=60 # Aerospike ./wait4it -type=aerospike -h=127.0.0.1 -p=3000 -t=60
可在Docker容器中运行,也可作为K8s/OpenShift初始化容器。镜像地址:docker pull ph4r5h4d/wait4it
检查TCP端口
bashdocker run ph4r5h4d/wait4it -type=tcp -h=127.0.0.1 -p=8080 -t=60
检查MySQL实例
bashdocker run ph4r5h4d/wait4it -type=mysql -h=127.0.0.1 -p=3306 -t=60 -u=root -P=secret -n=app
检查PostgreSQL实例
bashdocker run ph4r5h4d/wait4it -type=postgres -h=127.0.0.1 -p=5432 -t=60 -u=postgres -P=secret -ssl=disable
检查HTTP响应
bashdocker run ph4r5h4d/wait4it -type=http -h=https://farshad.nematdoust.com -t=60 -http-status=200 -http-text="Software Engineer" docker run ph4r5h4d/wait4it -type=http -h=https://nematdoust.com -t=60 -http-status=301 -http-follow-redirect=false
检查其他服务
bash# MongoDB docker run ph4r5h4d/wait4it -type=mongo -p=32768 -t=60 -u=mongoadmin -P=secret -h=127.0.0.1 # Redis集群 docker run ph4r5h4d/wait4it -type=redis -p=6379 -t=60 -P=secret -operation-mode=cluster -h=127.0.0.1 # ElasticSearch docker run ph4r5h4d/wait4it -type=elasticsearch -h=http://127.0.0.1 -p=9200
环境变量优先级高于命令行参数,若同时设置,以环境变量为准。
http-text时仅检查状态码您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务