首页 > 解决方案 > docker build 在 Kubernetes 节点中失败

问题描述

使用 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

它创建了 2 个节点和一个主节点,我尝试设置 Jenkins docker build slave 以在 pod 中构建 docker 映像

我的构建失败了

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

当我登录节点并运行相同的构建时,它在那里失败了,似乎 docker daemon 没有得到 DNS resoultion

请帮忙

标签: dockerjenkinskubernetes

解决方案


尝试指定 Docker 构建选项--network host。即使主机可以,我也看到了 Docker 容器无法到达网络的地方。


推荐阅读