指定--tag时需Dockerfile,gcloud builds submit报错如何解决?
解决gcloud builds submit报错的方案
当执行命令时出现ERROR: (gcloud.builds.submit) Invalid value for [source]: Dockerfile required when specifying --tag错误,即使当前目录存在Dockerfile,可通过以下方式修改命令实现成功构建:
- 显式指定构建上下文为当前目录,让命令明确识别Dockerfile所在路径:
gcloud builds submit --tag gcr.io/hello-python-app/helloyoutube . - 若需要更精准控制,也可以显式指定Dockerfile的位置:
gcloud builds submit --tag gcr.io/hello-python-app/helloyoutube --dockerfile=Dockerfile .
报错原因
gcloud builds submit命令需要明确构建上下文(即包含Dockerfile及相关构建文件的目录),原命令未指定构建上下文路径,导致命令无法定位到当前目录下的Dockerfile,从而抛出错误。添加.表示以当前目录作为构建上下文,命令会自动在该目录下查找Dockerfile完成镜像构建。
内容的提问来源于stack exchange,提问作者VANSHIKA SINGOLIA
相关产品推荐
相关产品推荐

