Can we build a docker image using .tar or zip archive
Solution 1
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
Solution 2
You can use docker load
command to get more information visit
Related videos on Youtube
Abdul Rehman
Abdul Rehman is a hands-on developer,architect, consultant, trainer and community leader focused on helping companies and individuals by providing Web & Cloud based solutions using various tools and technologies like Drupal, WordPress, Python, Django, JavaScript, Google Cloud Platform, AWS and Docker.
Updated on June 04, 2022Comments
-
Abdul Rehman almost 2 years
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!
-
Abdul Rehman almost 7 yearsactually I was trying to build docker image using a tar which uploads by user on my django app and include dockerfile, bu it return
invalid tar header
error.