title: How does docker container access Internet
body: <p>I have docker installed (Docker for Mac).
  I start a new container with</p>
  
  <pre><code>docker run -it ubuntu
  </code></pre>
  
  <p>I can see that my newly created container has internet access by simply invoking</p>
  
  <pre><code>ping google.com
  </code></pre>
  
  <p>I see:</p>
  
  <pre><code>root@b06e1a46cc40:/# ping google.com
  PING google.com (216.58.209.14) 56(84) bytes of data.
  64 bytes from sof01s12-in-f14.1e100.net (216.58.209.14): icmp_seq=1 ttl=37 time=63.0 ms
  64 bytes from sof01s12-in-f14.1e100.net (216.58.209.14): icmp_seq=2 ttl=37 time=63.7 ms
  64 bytes from sof01s12-in-f14.1e100.net (216.58.209.14): icmp_seq=3 ttl=37 time=64.8 ms
  </code></pre>
  
  <p>Next, I checked the networks that my container is connected to:</p>
  
  <pre><code>root@b06e1a46cc40:/# ip addr show
  1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
      inet 127.0.0.1/8 scope host lo
         valid_lft forever preferred_lft forever
  2: tunl0@NONE: &lt;NOARP&gt; mtu 1480 qdisc noop state DOWN group default qlen 1
      link/ipip 0.0.0.0 brd 0.0.0.0
  3: ip6tnl0@NONE: &lt;NOARP&gt; mtu 1452 qdisc noop state DOWN group default qlen 1
      link/tunnel6 :: brd ::
  6: eth0@if7: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc noqueue state UP group default
      link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
      inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
         valid_lft forever preferred_lft forever
  root@b06e1a46cc40:/#
  </code></pre>
  
  <p>As I understand, eth0 is used to access internet - it is a network 172.17.0.0/16.</p>
  
  <p>When I look at network list of my host, I'm not connected to this network.</p>
  
  <p>How does my container access internet then?</p>
  
  <p>As I understand it, my container should access internet through my host, because, after all, my host is connected to internet, so this is the only way to access.</p>