使用dockerfile构建映像 [英] Build image using dockerfile
问题描述
有人使用以下命令成功构建映像吗?
Has anyone ever successfully build an image using following command?
curl -v -X POST \
-H "Content-Type:application/tar" \
http://52.212.221.156:2375/build?t=samplerepo&dockerfile="C:\Dockerfile.tar.gz"
即使文件位于指定位置,我也遇到以下错误
Even though file is on specified location, I'm getting following error
{"message":"Cannot locate specified Dockerfile: Dockerfile"}
或者如果有人使用 remote
参数完成此操作,请帮助
Or if at all anyone has done it using remote
parameter, please help
推荐答案
首先,请参考Docker API文档并仔细阅读所有查询参数 https://docs.docker.com/engine/api/v1.25/#operation/ImageBuild 。
Firstly, refer Docker API documentation and go through all the query parameters https://docs.docker.com/engine/api/v1.25/#operation/ImageBuild.
有使用dockerfile构建映像的三种方法
There are three way to build an image using dockerfile
-
使用包含您的dockerfile的远程URL tar格式
Using a remote url, which has your dockerfile in tar format
curl -X POST http:// localhost:5000 / build?remote = https://raw.githubusercontent.com /abha10/FirstGitProj/master/Dockerfile.tar
使用远程URL以及dockerfile上下文路径
Using remote url as well as dockerfile context path
curl -X POST http:// localhost:5000 / build?dockerfile = Tomcat / config / Dockerfile& remote = https://raw.githubusercontent.com /abha10/FirstGitProj/master/Tomcat.tar
以下内容在其官方文档中不可用,但如果在如果您的dockerfile在本地。
Following is not available in their official document but works fine, if in case you have your dockerfile present locally.
curl -X POST -H Content-Type:application / tar --data-binary' @ Dockerfile.tar.gz' http:// localhost:5000 / build?tag = tomcat
这篇关于使用dockerfile构建映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!