I have created an ec2 instance in AWS. I have successfully installed Docker and am able to get containers running successfully. However, I am unable to get the two containers to communicate with one another. Specifically, I'm attempting to get a Prometheus container (port 9090) to communicate with Alertmanager container (port 9093).
I've tried standard port mappings with bridge network mode, and I've tried host network mode. But to no avail.
Is there any special magic required to get two containers talking to one another on ec2 on localhost?
My Prometheus config:
rule_files:
- 'alert.rules'
scrape_configs:
- job_name: prometheus
static_configs:
- targets:
- localhost:9090
alerting:
alertmanagers:
- static_configs:
- targets:
- localhost:9093
The output of docker ps
:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1c83d903a274 prom/prometheus "/bin/prometheus --c…" 22 hours ago Up 22 hours 0.0.0.0:9090->9090/tcp cranky_banach
d1404c0ee182 prom/alertmanager "/bin/alertmanager -…" 22 hours ago Up 22 hours 0.0.0.0:9093->9093/tcp competent_chatterjee
Here is a sample Prometheus log line from CloudWatch:
level=error ts=2019-07-19T20:31:36.001Z caller=notifier.go:528 component=notifier alertmanager=http://localhost:9093/api/v1/alerts count=1 msg="Error sending alert" err="Post http://localhost:9093/api/v1/alerts: dial tcp 127.0.0.1:9093: connect: connection refused"
Here is the output of docker inspect bridge
:
[
{
"Name": "bridge",
"Id": "8ce9c8be6d071b098930a40873d54c5a6da68bcba91404e360cd0ca4532b365d",
"Created": "2019-07-19T10:02:37.509745972Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"1c83d903a2742a95323c626cb2e9a556908e6701790af79d61f8f9cf453acc0d": {
"Name": "cranky_banach",
"EndpointID": "23e33b9b0e2f2af24bd6da870bad625fe3d111d92f47a9fdf16d253eba9e3889",
"MacAddress": "02:42:ac:11:00:03",
"IPv4Address": "172.17.0.3/16",
"IPv6Address": ""
},
"d1404c0ee18280a80fcfa96e7df3bfa5ff023a58f70b3bac67c23b31de7994df": {
"Name": "competent_chatterjee",
"EndpointID": "49b38cbf678abd3942f1d8b2a65f8b353b9e8e228cc84a9311cd1ac6549ddc96",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
You need to use host network mode when you are looking for container to container networking. Bridge networking (unless you use user defined bridge mode) does not expose containers to each other in the docker daemon. It's security and isolation mode.
https://docs.docker.com/network/bridge/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With