Answers: <p>In my opinion k8s should not be used to build docker images as it is an orchestration platform, but there is an <a href="https://github.com/kubernetes/kubernetes/issues/1806" rel="nofollow noreferrer">open issue in the GitHub k8s repository</a>. In conclusion, building docker images on a k8s cluster seems not to be possible at the moment.</p>
  
Answers: CC BY-SA 3.0
Answers: 2017-12-02T12:08:44.663Z
Answers: I was able to resolve it long ago. There was an issue with iptables rules because of conflicts with flannel interface. As a result rules for docker0 bridge interface were not applied correctly after each server reboot. Now everything is being worked properly. Thank you!
Answers: user54
Answers: CC BY-SA 3.0
Answers: 2017-11-30T23:01:17.333Z
Answers: 2017-11-30T23:01:17.333Z
Answers: 030
Body: <p>I have a Kubernetes pod based on a Jenkins/slave container to which I mount a Docker socket and a Docker binary file with necessary kernel modules in privileged mode. </p>
  
  <p>Inside that pod I build a Docker image, in which I run Docker container. Inside that container I don't have Internet connection at all because the pod container uses a flannel network <code>(198.x.x.x)</code> and that container uses bridged docker network <code>(172.x.x.x)</code>, which is not available inside the pod container. </p>
  
  <p>How can I make the Internet available inside the second container which is being created inside the Kubernetes pod container? </p>
  
  <p>Using Docker API in Jenkins pipeline is not a solution for me as long as it limits output of error logs and I can not commit changes made in the second container because of immediate removing of that container after build.</p>
  
Comments: CC BY-SA 4.0
Comments: 2019-03-26T03:41:57.400Z
Comments: I have a similar problem, I don’t have access to the external network from the Pod. How did you resolve iptables conflict?
Comments: khesl
Tags: <docker><kubernetes>
Title: Internet connection inside Docker container in Kubernetes
UserDisplayName: user54
ThreadText: # Internet connection inside Docker container in Kubernetes
  
  (Asked by: username_0 on 2017-10-29)
  
  I have a Kubernetes pod based on a Jenkins/slave container to which I mount a Docker socket and a Docker binary file with necessary kernel modules in privileged mode.
  
  Inside that pod I build a Docker image, in which I run Docker container. Inside that container I don't have Internet connection at all because the pod container uses a flannel network `(198.x.x.x)` and that container uses bridged docker network `(172.x.x.x)`, which is not available inside the pod container.
  
  How can I make the Internet available inside the second container which is being created inside the Kubernetes pod container?
  
  Using Docker API in Jenkins pipeline is not a solution for me as long as it limits output of error logs and I can not commit changes made in the second container because of immediate removing of that container after build.
  
  **Tags:** docker, kubernetes
  
  > **Comments:**
  > **username_1**: I have a similar problem, I don’t have access to the external network from the Pod. How did you resolve iptables conflict?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-11-30. Score: 1 | Accepted answer
  
  In my opinion k8s should not be used to build docker images as it is an orchestration platform, but there is an [open issue in the GitHub k8s repository](https://github.com/kubernetes/kubernetes/issues/1806). In conclusion, building docker images on a k8s cluster seems not to be possible at the moment.
  
  > **Comments:**
  > **username_0**: I was able to resolve it long ago. There was an issue with iptables rules because of conflicts with flannel interface. As a result rules for docker0 bridge interface were not applied correctly after each server reboot. Now everything is being worked properly. Thank you!  
  
  ---
  
  