0

Am using spotify docker client to build docker images and at the time of building images, I want to specify network as host (--network=host is the command line equivalent) because if am not setting network type to host am having troubling downloading the python packages from the internet from inside the kubernetes container

I have tried setting network to host via DockerClient.BuildParam, but it's getting ignored and hence not working,

any idea on how can i get it work ?

    // Formulate Docker Build parameters
    DockerClient.BuildParam bp2 = DockerClient.BuildParam.create("dockerfile", "./DockerFile");
    DockerClient.BuildParam bp3 = DockerClient.BuildParam.create("network", "host");
    fqiName = fullyQualifiedImage.generateFullyQualifiedName();

    // Build Image
    logger.info("DockerBuild Parameters Set. Building image -> {}", fqiName);

    dockerClient.build(
        Paths.get(workspace.getTempDirPath()), fqiName, new DockerLoggingBuildHandler(), bp2, bp3);
Rajiv
  • 392
  • 6
  • 22
  • You dropped the word "Kubernetes" into the middle of this; can you add a little more context to this? (Kubernetes's network environment is especially complicated; you should normally be able to make outbound connections from either standard Docker or Kubernetes, and if you can't, I'd figure out why not instead of trying to hack around it with host networking.) – David Maze Apr 28 '20 at 12:58
  • @DavidMaze this is related to https://stackoverflow.com/questions/49299428/no-internet-connectivity-inside-docker-container-running-inside-kubernetes-with , we faced this issue in an other service as well which is using s2i driver for building docker images and we solved it by specifying network type as host over there and BTW here also I have figured the issue i.e the flag name is "networkmode" and not "network", on GKE we didn't faced any of these issue but on on-prem kubernetes clusters we were facing these issues https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild – Rajiv Apr 28 '20 at 14:06

0 Answers0