title: Enable Docker Bridge Network on AWS Linux AMI 2
body: <p>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).</p>
  
  <p>I've tried standard port mappings with bridge network mode, and I've tried host network mode. But to no avail.</p>
  
  <p>Is there any special magic required to get two containers talking to one another on ec2 on localhost?</p>
  
  <p>My Prometheus config:</p>
  
  <pre><code>rule_files:
    - 'alert.rules'
  scrape_configs:
    - job_name: prometheus
      static_configs:
       - targets:
          - localhost:9090
  alerting:
    alertmanagers:
     - static_configs:
        - targets: 
          - localhost:9093
  </code></pre>
  
  <p>The output of <code>docker ps</code>:</p>
  
  <pre><code>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-&gt;9090/tcp   cranky_banach
  d1404c0ee182        prom/alertmanager   "/bin/alertmanager -…"   22 hours ago        Up 22 hours         0.0.0.0:9093-&gt;9093/tcp   competent_chatterjee
  </code></pre>
  
  <p>Here is a sample Prometheus log line from CloudWatch:</p>
  
  <pre><code>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"
  </code></pre>
  
  <p>Here is the output of <code>docker inspect bridge</code>:</p>
  
  <pre><code>[
      {
          "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": {}
      }
  ]
  </code></pre>