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"}
Or if at all anyone has done it using remote
parameter, please help
The query parameter dockerfile
shall point to the Dockerfile within the build context i.e, with in the tar archive that you are posting along with request.
Assume the below structure in the archive
payload.tar.gz
-- config
-- Dockerfile
-- src
-- temp
Then your query parameter "dockerfile" shall hold config/Dockerfile.
Ensure you are sending tar payload along with the request.
Following command creates an image on the local environment via Docker Remote API
curl -v POST -H "Content-Type: application/tar" --data-binary @Dockerfile.tar.gz --unix-socket /var/run/docker.sock http:/build?t=sample
Firstly, refer Docker API documentation and go through all the query parameters https://docs.docker.com/engine/api/v1.25/#operation/ImageBuild.
There are three way to build an image using dockerfile
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"
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"
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"