Docker容器不健康,但日志中没有错误

10
我正在使用官方的docker-compose文件来启动 airflow
我的某些容器似乎不健康:
34d8698d67e7   apache/airflow:2.0.2   "/usr/bin/dumb-init …"   31 minutes ago   Up 28 minutes (unhealthy)   0.0.0.0:5555->5555/tcp, :::5555->5555/tcp, 8080/tcp   airflow_flower_1
a291cf238b9f   apache/airflow:2.0.2   "/usr/bin/dumb-init …"   31 minutes ago   Up 29 minutes               8080/tcp                                              airflow_airflow-init_1
fdb20e9152f3   apache/airflow:2.0.2   "/usr/bin/dumb-init …"   31 minutes ago   Up 29 minutes (unhealthy)   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp             airflow_airflow-webserver_1
abf5a16aa846   apache/airflow:2.0.2   "/usr/bin/dumb-init …"   31 minutes ago   Up 29 minutes               8080/tcp                                              airflow_airflow-worker_1
f6dc352f407b   apache/airflow:2.0.2   "/usr/bin/dumb-init …"   31 minutes ago   Up 28 minutes               8080/tcp                                              airflow_airflow-scheduler_1
12dfc71e518f   redis:latest           "docker-entrypoint.s…"   31 minutes ago   Up 29 minutes (healthy)     0.0.0.0:6379->6379/tcp, :::6379->6379/tcp             airflow_redis_1

然而,例如其中一个日志并不十分详尽。

# docker logs -f fdb20e9152f3
WARNING! You should run the image with GID (Group ID) set to 0
         even if you use 'airflow' user (UID=50000)
 You started the image with UID=50000 and GID=50000
 This is to make sure you can run the image with an arbitrary UID in the future.
 See more about it in the Airflow's docker image documentation
     http://airflow.apache.org/docs/docker-stack/entrypoint
BACKEND=postgresql+psycopg2
DB_HOST=my-db-endpoint
DB_PORT=5432
WARNING! You should run the image with GID (Group ID) set to 0
         even if you use 'airflow' user (UID=50000)
 You started the image with UID=50000 and GID=50000
 This is to make sure you can run the image with an arbitrary UID in the future.
 See more about it in the Airflow's docker image documentation
     http://airflow.apache.org/docs/docker-stack/entrypoint
BACKEND=postgresql+psycopg2
DB_HOST=my-db-endpoint
DB_PORT=5432

无论出现任何与airflow相关的问题,我应该如何检查docker中正在发生的事情呢?

Docker似乎意识到有几个容器不健康。

编辑:两个失败的容器都具有healtcheck条件。

healthcheck:
      test: ["CMD", "curl", "--fail", "http://localhost:5555/"]

并且

healthcheck:
      test: ["CMD", "curl", "--fail", "http://localhost:8080/"]

看起来该过程正在失败,可以通过查看其 inspect 输出来确认。

 Failed to connect to localhost port 8080: Connection refused

但我无法确定是什么导致了失败。

编辑:我也尝试了先启动init服务的指示。

# docker-compose up airflow-init
Starting airflow_redis_1 ... done
Starting airflow_airflow-init_1 ... done
Attaching to airflow_airflow-init_1
airflow-init_1       | BACKEND=postgresql+psycopg2
airflow-init_1       | DB_HOST=my-db-endpoint
airflow-init_1       | DB_PORT=5432

但它永远不会退出,只会打印上面的消息,就是这样...


你执行了 docker-compose up airflow-init 吗? - Elad Kalif
这是其中一个服务,只需要运行 docker-compose up 就可以了,不是吗? - pkaramol
最奇怪的部分(首先)是我在日志中看到的唯一内容就是我在问题中打印的消息。 - pkaramol
1
你是否按照文档中的说明进行操作了?https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html#docker-compose-yaml - Elad Kalif
是的,请检查我在问题上的新编辑。 - pkaramol
如果到 http://localhost:8080 的curl请求失败,则可能存在防火墙或其他网络问题,阻止对该端口的访问。您能在浏览器中查看Airflow Web服务器GUI吗? - 7yl4r
4个回答

1

我遇到了类似的问题,原因是docker卷引起的。由于我在我的mac上运行了很多容器,导致磁盘空间不足。我通过修剪docker卷来解决了这个问题。

docker volume prune

这将删除您的mac book上未使用的任何卷。在运行此命令之前,请检查是否有任何有用的数据。


0

对于docker-compose,从入口点开始,组ID的默认值为0。

"${AIRFLOW_UID:-50000}:${AIRFLOW_GID:-0}"

编辑您的docker-compose.yaml文件或添加env.sh文件到Airflow项目仓库中。


0

我遇到了类似的问题,而且是由于“healthcheck”引起的。我使用默认容器用户运行它们。

为了尝试一下,我将健康检查命令更改为使用airflow用户启动,如下所示:

$ runuser -u airflow -- <healthckeck command>

这样就解决了。从现在开始,我将更改运行docker compose up的用户为airflow


0

这似乎是由于分配给运行此镜像的Docker的内存不足而导致的错误,请尝试增加可用于Docker的资源并看到魔法


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接