docker build failing in kubernetes nodes

9/19/2018

Had setup K8s cluster using Kops

export KOPS_STATE_STORE=s3://clusters.aind.devops
export ZONES=ap-south-1a
export VPC=vpc-xxxxx
export node_count=2
export node_size=m4.large
export master_size=t2.medium
export api_loadbalancer_type=public
export topology=private
export dns=private
export dns_zone=Z25L42E21ILH89
export CLIENT=test

It created 2 node and one master And i tried to setup Jenkins docker build slave to build the docker images in the pod

My build is failing with

Sending build context to Docker daemon 15.36 kB
Step 1/3 : FROM ubuntu
 ---> cd6d8154f1e1
Step 2/3 : RUN apt-get update -y
 ---> Using cache
 ---> 8007c6693623
Step 3/3 : RUN apt-get install vim -y
 ---> Running in cbbafcb6a37b
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package vim
The command '/bin/sh -c apt-get install vim -y' returned a non-zero code: 100

When I logged into the node and ran the same build its failing there, seems docker daemon is not getting the DNS resoultion

Please help

-- renuraj
docker
jenkins
kubernetes

1 Answer

9/19/2018

Why are you building images in the cluster? The proper way to do it would be to:

  1. host jenkins on another server
  2. build images over there
  3. push the images to a local docker registry
  4. and then run the images on the k8s cluster by pulling from the registry

creating a local docker registry:

As for why it can't locate the vim package check network connectivity by pinging 8.8.8.8 . By default, if the node has internet connectivity, the docker daemon has too.

-- the_dangoria
Source: StackOverflow