我跟着跑docker-compose.yml。请注意,我故意将 healthcheck/test 部分中的用户和数据库名称更改为错误的名称(“错误”意味着它们不等于 POSTGRES_USER 和 POSTGRES_DB 值)。
version: "3.8"
services:
db:
container_name: some-db-container
image: postgres:14.1-alpine
ports:
- "5438:5432"
environment:
POSTGRES_USER: someuser
POSTGRES_PASSWORD: somepass
POSTGRES_USER: somedb
healthcheck:
test: [ "CMD-SHELL", "pg_isready -q -U anotheruser -d anotherdb" ]
Run Code Online (Sandbox Code Playgroud)
当我这样做时,docker ps我可以看到容器some-db-container被标记为,healthy但我希望它是这样unhealthy,因为我传递了错误的用户名和密码。为什么标记为healthy?