Overview

Full name
docker.io/djbasster/wait-for-it
Registry
docker.io
Namespace
djbasster
Repository
wait-for-it
Cached tags
4
Last synced
07/06/2026, 11:58 AM

Introduction

wait-for-it 轻量 TCP 就绪探测 CLI 镜像,在 Compose 启动链中阻塞至依赖端口可用,常用于数据库先于应用启动。

Details

djbasster/wait-for-it 封装经典 wait-for-it.sh 脚本,以指定 host:port 为条件轮询连接直至成功或超时退出。典型作为 docker-compose 中 app 容器的 entrypoint 前缀,解决 MySQL/Redis 尚未 listen 时应用 crash loop 问题,与 dockerize 相比无额外依赖、体积极小。定位为 init/entrypoint 辅助 CLI,以 --rm 一次性运行,独立在线服务。

快速启动

docker run --rm \
  docker.io/djbasster/wait-for-it:latest \
  mysql:3306 -- echo "mysql is up"

推荐实践

docker run --rm \
  docker.io/djbasster/wait-for-it:2020-06-09 \
  -t 60 -s mysql.internal:3306 -- \
  sh -c "echo ready && exec your-app"

核心参数说明

  • host:port — 待探测的目标地址
  • -t 60 — 最长等待秒数(超时非零退出)
  • -s — 严格模式,超时失败
  • -- — 分隔符,其后为就绪后执行的命令
  • 定位 — entrypoint/init 辅助,非常驻服务
  • 固定 tag — 脚本行为 pin

Latest tags (20)

View all 4 tags →
TagArchPushed AtSizeDigestSyncWishAction
docker.io/djbasster/wait-for-it
:latest
linux/arm64linux/amd64
2025/02/11 17:010.0 MBsha256:5d5a4c6c9e9d
docker.io/djbasster/wait-for-it
:bash
linux/arm64linux/amd64
2025/02/11 17:016.5 MBsha256:ad34365ee84a
docker.io/djbasster/wait-for-it
:bookworm
linux/arm64linux/amd64
2025/02/06 19:3426.8 MBsha256:184305577780
docker.io/djbasster/wait-for-it
:stretch
linux/amd64
2025/02/06 19:3321.7 MBsha256:8179a83fa062