docker - 解析 dockerfile 路径时出错:请使用 --dockerfile 在构建上下文中提供 Dockerfile 的有效路径
问题描述
apiVersion: v1
kind: Pod
metadata:
name: kaniko
spec:
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:latest
args:
- "--context=dir:///workspace"
- "--dockerfile=/workspace/Dockerfile"
- "--destination=gcr.io/kubernetsjenkins/jenkinsondoc:latest"
volumeMounts:
- name: kaniko-secret
mountPath: /secret
- name: context
mountPath: /workspace
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /secret/kaniko-secret.json
restartPolicy: Never
volumes:
- name: kaniko-secret
secret:
secretName: kaniko-secret
- name: context
hostPath:
path: /home/sabadsulla/kanikodir
我在 kubernetes pod 上运行 kaniko 以构建 docker 映像并推送到 GCR。
当我为 CONTEXT_PATH 使用谷歌云存储时,它工作正常,但我需要使用 Local_directory(意味着使用 pod 的共享卷)作为 CONTEXT_PATH 它会引发错误
"Error: error resolving dockerfile path: please provide a valid path to a Dockerfile within the build context with --dockerfile
用法:
I tried with args "--context=/workspace" , "--context=dir://workspace" , it gives the same error
解决方案
该文件夹看起来像
在主机:
/home/sabadsulla/kanikodir/Dockerfile
当它变成 PV/PVC 时,在 pod 容器中
/workspace/Dockerfile
那么对于kanino executor
,如果我们将上下文映射到workspace
,dockerfile将与上下文相关Dockerfile
,所以
--context=/workspace
--dockerfile=Dockerfile
推荐阅读
- python-3.x - 用这种方式添加矩阵元素
- javascript - 当设备宽度等于手机宽度时,如何访问其他 html 文件?
- javascript - JQuery 根据另一个输入框是否有值来切换输入框
- jquery - 被 CORS 策略阻止:不允许请求标头字段 access-control-allow-origin
- c# - Xamarin Forms Picker - 如何设置标题的行高/删除标题内的填充?
- mongodb - Mongodb返回错误的计数
- sql - 如何修复此错误“子查询返回超过 1 个值。当子查询遵循 =、!=、<、<=、>、>= 时,这是不允许的
- node.js - 如何获取流或文件描述符的当前偏移量?
- rx-java - 如何在 Spring Flux 中停止昂贵的计算
- regex - 使用 Node.js 从文件中解析 PHP 会话数据