简体   繁体   English

docker build 在 kubernetes 节点中失败

[英]docker build failing in kubernetes nodes

Had setup K8s cluster using Kops使用 Kops 设置了 K8s 集群

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它创建了 2 个节点和一个主节点,我尝试设置 Jenkins docker build slave 以在 pod 中构建 docker 镜像

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当我登录节点并运行相同的构建时,它在那里失败了,似乎 docker daemon 没有获得 DNS 解析

Please help请帮忙

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将图像推送到本地 docker 注册表
  4. and then run the images on the k8s cluster by pulling from the registry然后通过从注册表中拉取在 k8s 集群上运行图像

creating a local docker registry:创建本地 docker 注册表:

As for why it can't locate the vim package check network connectivity by pinging 8.8.8.8 .至于为什么找不到vim包通过ping 8.8.8.8检查网络连接。 By default, if the node has internet connectivity, the docker daemon has too.默认情况下,如果节点具有 Internet 连接,则 docker 守护程序也具有。

Try specifying Docker build option --network host .尝试指定 Docker 构建选项--network host I have seen where Docker containers cannot reach the network even if the host can.我已经看到了即使主机可以访问 Docker 容器也无法访问网络的地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM