Prometheus 官方 Docker image 的一个 bug

简介

最近发现了一个 Prometheus 官方 Docker image(https://hub.docker.com/u/prom) 生成的容器不能解析同一个 自定义 bridge 上的其他 Docker 容器的容器名的问题。

一些情况

  1. 我的环境是 PVE 7.* 里的一个 vm,跑的操作系统是 Debian 12(bookworm),docker 版本是 28.0.2
  2. 多个容器公用的是一个较 bridge111 的 自定义 bridge,地址段是:172.18.0.0/16
  3. 其中还跑的有 grafana 官方的容器:grafana 和 loki,从这两个容器里可以正确解析其他所有 bridge111 下的容器的容器名
  4. prometheus 官方 docker image 的容器,都不能正确解析 bridge111 下所有容器的容器名(会出 “bad address” 的报错提示),但是能正确解析互联网域名,比如 baidu.com
  5. 发现 prometheus 的这一些 docker image 都是基于 quay.io/prometheus/busybox,而 quay.io/prometheus/busybox 又是指向的 quay.io/prometheus/busybox:uclibcquay.io/prometheus/busybox:uclibc 基于的 busybox:uclibc
  6. quay.io/prometheus/busybox:uclibc 创建容器试了一下,果然不能解析容器名,但可以解析互联网域名
  7. quay.io/prometheus/busybox:glibc 试了一下,则没有任何问题
  8. 再用 busybox:uclibc 试了一下,也不行,都是 “bad address”

所以差不多水落石出,busybox:uclibc 这个 image 的锅。

环境介绍

BTW, 我的版本如下:

  • Debian 12(bookworm)
  • kernel 6.1.0
  • docker 28.0.2
  • prometheus: v2.53.4
  • alertmanager: v0.27.0
  • blackbox-exporter: v0.25.0
  • snmp-exporter: v0.28.0

参考

  • https://github.com/prometheus/busybox/issues/18