title: "internet connection issue" while creating Docker Image
body: <p>I have a CentOS 7.0 host machine Docker version 19.03.4, build 9013bf583a installed. I am trying to create a simple docker image</p>
  
  <p>I have a the following Docker file.</p>
  
  <pre><code>FROM alpine:edge
  MAINTAINER javaonfly
  RUN apk update &amp;&amp; apk add --no-cache openjdk8
  </code></pre>
  
  <p>(Please note that I have updated the RUN command to have "update" based on the answer given by LinPy below) 
  In the above docker file, I am simply using alpine:edge as base docker container and then update it with openjdk8. I then execute the following command</p>
  
  <pre><code>sudo docker build --network=host --file=docker.txt --tag=myrep/image1 --rm=true .
  </code></pre>
  
  <p>I see the following output</p>
  
  <pre><code>Sending build context to Docker daemon  87.04MB
  Step 1/3 : FROM alpine:edge
   ---&gt; 7eacb6761fa1
  Step 2/3 : MAINTAINER javaonfly
   ---&gt; Using cache
   ---&gt; 77818d634212
  Step 3/3 : RUN apk update &amp;&amp; add --no-cache openjdk8
   ---&gt; Running in d438f2522d6a
  fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
  fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
  ERROR: http://dl-cdn.alpinelinux.org/alpine/edge/main: network error (check Internet connection and firewall)
  WARNING: Ignoring APKINDEX.066df28d.tar.gz: No such file or directory
  ERROR: http://dl-cdn.alpinelinux.org/alpine/edge/community: network error (check Internet connection and firewall)
  WARNING: Ignoring APKINDEX.b53994b4.tar.gz: No such file or directory
  2 errors; 14 distinct packages available
  The command '/bin/sh -c apk update &amp;&amp; add --no-cache openjdk8' returned a non-zero code: 2
  </code></pre>
  
  <p>On the host machine, I can successfully run the command docker run hello-world. I can also ping to www.google.com from host machine. But, it seems the alpine:edge container is not able to connect to internet. </p>
  
  <p>I have also shelled into alpine:edge container with this command and executed the command ping www.google.com inside the shell, but the ping is stuck with no result. </p>
  
  <pre><code>sudo docker run -it --rm alpine:edge
  </code></pre>
  
  <p>Following is the result of the <strong>ifconfig</strong> command in the alpine:edge shell</p>
  
  <pre><code>eth0      Link encap:Ethernet  HWaddr 02:42:C0:A8:DC:01
            inet addr:192.168.220.1  Bcast:192.168.220.255  Mask:255.255.255.0
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:9 errors:0 dropped:0 overruns:0 frame:0
            TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:0
            RX bytes:698 (698.0 B)  TX bytes:630 (630.0 B)
  
  lo        Link encap:Local Loopback
            inet addr:127.0.0.1  Mask:255.0.0.0
            UP LOOPBACK RUNNING  MTU:65536  Metric:1
            RX packets:0 errors:0 dropped:0 overruns:0 frame:0
            TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
  </code></pre>
  
  <p>following is the result of the <strong>ip addr show</strong> command on the host machine.</p>
  
  <pre><code>1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
      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
      inet6 ::1/128 scope host
         valid_lft forever preferred_lft forever
  2: ens33: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
      link/ether 00:50:56:bf:b9:c6 brd ff:ff:ff:ff:ff:ff
      inet 10.211.164.24/32 brd 10.211.164.24 scope global noprefixroute ens33
         valid_lft forever preferred_lft forever
      inet6 fe80::250:56ff:febf:b9c6/64 scope link noprefixroute
         valid_lft forever preferred_lft forever
  16: docker0: &lt;NO-CARRIER,BROADCAST,MULTICAST,UP&gt; mtu 1500 qdisc noqueue state DOWN group default
      link/ether 02:42:6f:8a:2e:79 brd ff:ff:ff:ff:ff:ff
      inet 192.168.220.2/24 brd 192.168.220.255 scope global docker0
         valid_lft forever preferred_lft forever
      inet6 fe80::42:6fff:fe8a:2e79/64 scope link
         valid_lft forever preferred_lft forever
  </code></pre>
  
  <p>I have gone through many questions in SO related to this issue, but none of them solved my issue.</p>