title: Cannot access HTTP from inside Docker container on bridge network
body: <p>My development environment is in Vagrant (VirtualBox) Linux server that has MySQL (port 3306) and Tomcat (port 18080) running on it. This is the host server that I run Docker on.</p>
  <p>I need to run another service inside docker that connects to MySQL and Tomcat server on the host as well as any outside web server.</p>
  <p>I found that connection to MySQL to the host is fine. However, connection to HTTP (port 80 or 443) will time out. If I run the same Docker image on my Mac (outside Vagrant), I can connect to both MySQL and any outside web server).</p>
  <p>Here's the details:</p>
  <p>On my host (Vagrant)</p>
  <pre><code>[root@my Downloads]# ip addr show docker0
  3: docker0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc noqueue state UP group default 
      link/ether 02:42:95:b0:5e:47 brd ff:ff:ff:ff:ff:ff
      inet 192.168.100.1/24 brd 192.168.100.255 scope global docker0
         valid_lft forever preferred_lft forever
      inet6 fe80::42:95ff:feb0:5e47/64 scope link 
         valid_lft forever preferred_lft forever
  [root@my Downloads]# 
  </code></pre>
  <p>I get into Docker and tried to connect to host's MySQL. This works fine.</p>
  <pre><code>[root@my Downloads]# docker exec -it myDocker sh
  /opt/myDocker # nc 192.168.100.1 3306
  Q
  5.7.26-29-logf&quot;}1
                   Q&amp;
                     ??S???&amp;z GTP[a{mysql_native_passwordasdasd
  !??#08S01Got packets out of order^Cpunt!
  
  /opt/myDocker # 
  </code></pre>
  <p>But if I tried to connect to HTTP, it doesn't work.</p>
  <pre><code>/opt/myDocker # nc 192.168.100.1 18080
  /opt/myDocker # nc www.google.com 80
  GET /
  /opt/myDocker # GET /
  sh: GET: not found
  /opt/myDocker # 
  </code></pre>
  <p>Connection to my host's Tomcat on 18080 will just return back to prompt. The one to google.com will just hung there for some time then gets back to prompt.</p>
  <p>I tried the below as mentioned in <a href="https://docs.docker.com/network/bridge/" rel="nofollow noreferrer">https://docs.docker.com/network/bridge/</a> on the host (Vagrant VM) but it didn't help.</p>
  <pre><code>sysctl net.ipv4.conf.all.forwarding=1
  iptables -P FORWARD ACCEPT
  </code></pre>
  <p>I'm out of ideas. Can someone help?</p>
  <p>EDIT 1:
  I think this must be something to do with the bridged networking. I tried on another docker on the same VM with host networking and it's fine.</p>
  <pre><code>/dokcer2 # nc 192.168.100.1 18080
  GET /
  
  
  
  &lt;!DOCTYPE html &gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,initial-scale=1,shrink-to-fit=no&quot;&gt;
      &lt;meta name=&quot;theme-color&quot; content=&quot;#000000&quot;&gt;
      &lt;link rel=&quot;shortcut icon&quot; href=&quot;/auth/images/favicon.ico?v=13&quot;/&gt;
      &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/auth/static/styles/main.a7589877fc3cc07b7ac7.css&quot;/&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;noscript&gt;You need to enable JavaScript to run this app.&lt;/noscript&gt;
  &lt;div id=&quot;loginAppRoot&quot;&gt;&lt;/div&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;/auth/static/js/main.f5071db7f71c2283a0f9.js&quot;&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;^Cpunt!
  
  /docker2 # nc www.google.com 80
  GET /
  HTTP/1.0 200 OK
  Date: Sun, 15 Nov 2020 05:21:20 GMT
  Expires: -1
  Cache-Control: private, max-age=0
  Content-Type: text/html; charset=ISO-8859-1
  ... yada yada yada redacted ...
  </code></pre>