Can we build a docker image using tarball or zip archive which includes dockerfile inside that. I need to build a image from archives by using docker api.
Is there any reference or resource , I have search for 3o minutes but couldn't find anything.
Help me, please! Thanks in advance!
yes a dockerimage can be build from a tarball containing the Dockerfile
.
Let's assume we have a dockerfile called myDockerfile
which contains the following scripts
FROM ubuntu
COPY ./venv /
CMD ["/bin/bash"]
myDockerFile
is present inside the folder dockerfiles
FOLDER --> dockerfiles
FILE -----------> myDockerFile
the tarball for folder dockerfiles
is called dockerfiles.tar
the docker command to build the image will be:-
cat dockerfiles.tar | docker build - -f dockerfiles/myDockerFile -t mydockerimage
note:-
-f denotes the docker file in context to the tarball , if the dockerfile is called 'Dockerfile'
then there is no need to mention the name of the filename verbose