大家;我正在尝试在 telegram.conf 文件中访问主机上的 Jolokia 进程,但我的 telegraf 无法访问主机上的进程。
这是我的 docker-compose
version: "3"
services:
atom:
image: boomi/atom:5.0.2-rhel
container_name: eyer-observability
platform: linux/amd64
volumes:
- /Users/amarachiiheanacho/Documents/boomi-atom/data:/mnt/boomi:Z
environment:
- BOOMI_ATOMNAME=eyer-observability
- INSTALL_TOKEN=token
- BOOMI_ENVIRONMENTID=id
- ATOM_LOCALHOSTID=eyer-observability
ports:
- "9091:9090"
network_mode: host
telegraf:
image: telegraf:latest # Use the official Telegraf image
container_name: telegraf
volumes:
- /Users/amarachiiheanacho/Documents/boomi-atom/telegraf.conf:/etc/telegraf/telegraf.conf:ro # Mount your Telegraf configuration file (replace with the actual file path)
- /Users/amarachiiheanacho/Documents/boomi-atom/metrics.out:/metrics.out
ports:
- "8086:8086"
network_mode: host
如果我在终端上运行curl 进程,我会得到这个响应 卷曲 http://localhost:8080/jolokia/
{"request":{"type":"version"},"value":{"agent":"2.0.2","protocol":"7.3","details":{"agent_version":"2.0.2","agent_id":"172.20.10.2-23612-2bfb583b-servlet","server_product":"jetty","server_vendor":"Eclipse","server_version":"12.0.8","secured":false,"url":"http:\/\/172.20.10.2:8080\/jolokia"},"id":"172.20.10.2-23612-2bfb583b-servlet","config":{"maxDepth":"15","discoveryEnabled":"false","agentId":"172.20.10.2-23612-2bfb583b-servlet","maxCollectionSize":"0","debug":"false","canonicalNaming":"true","historyMaxEntries":"10","serializeException":"false","includeStackTrace":"false","maxObjects":"0","detectorOptions":"{}","debugMaxEntries":"100"},"info":{"proxy":{},"jmx":{}}},"status":200,"timestamp":1713470321}%",
如果我卷曲在电报中
curl http://localhost:8080/jolokia/
curl: (7) Failed to connect to localhost port 8080 after 4 ms: Couldn't connect to server
另外如何连接到正在运行的 dockeratom
Localhost 指的是容器本身。您不需要主机网络即可访问
host.docker.internal:8080
您使用其他容器的服务主机名连接到其他容器