简体   繁体   English

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

[英]Docker container unhealthy but no error in the logs

I am using the official docker-compose file of airflow to spin it up.我正在使用 airflow 的官方docker-compose 文件airflow它。

Some of my containers seem unhealthy:我的一些容器看起来不健康:

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

However the logs of one of them for example do not seem very informative.但是,例如其中之一的日志似乎信息量不大。

# 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

Regardless of any airflow - specific issues, how can I check docker - wise what's going on?不管任何airflow - 具体问题,我如何检查docker - 明智的是发生了什么?

Docker seems to be aware of a couple of containers not being healty. Docker 似乎意识到有几个容器不健康。

edit : both failing containers have the healtcheck condition编辑:两个失败的容器都有healtcheck条件

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

and

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

that seems to be failing by looking into their inspect output通过查看他们的inspect output 似乎失败了

 Failed to connect to localhost port 8080: Connection refused

but I cannot pinpoint what is causing the failure.但我无法确定导致失败的原因。

edit : I have tried following the instructions to start the init service first as well编辑:我也尝试按照说明首先启动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

but it never exits, it prints the above message and that's it...但它永远不会退出,它会打印上面的消息,就是这样......

I ran into similar issue and it was docker volume causing the issue.我遇到了类似的问题,是 docker 卷导致了这个问题。 As I was running lots of containers on my mac, there wasn;t enough disk space.当我在我的 Mac 上运行很多容器时,没有足够的磁盘空间。 I managed to fixed this issue my pruning the docker volume.我设法通过修剪 docker 卷解决了这个问题。

docker volume prune docker 卷修剪

This will remove any unused volume on your mac book.这将删除您的 mac book 上所有未使用的卷。 Before running this command please check if you got any useful data.在运行此命令之前,请检查您是否有任何有用的数据。

For docker-compose, from the entrypoint, the default value of group id is 0.对于 docker-compose,从入口点来看,组 id 的默认值为 0。

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

Edit your docker-compose.yaml file or ad ass env.sh file in your Airflow project repository.在 Airflow 项目存储库中编辑 docker-compose.yaml 文件或 ad ass env.sh 文件。

It does seems to be an error due to less memory allocated to docker for running this image, try to increase the resources available to docker and see the magic由于分配给 docker 用于运行此图像的 memory 较少,这似乎是一个错误,尝试增加 docker 的可用资源并查看魔法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM