I am getting below error while I am building docker image using Jenkins Pipeline. I have created Dockerfile in the GitHub.
Please find the below Jenkins File which I used.
Pipeline {
stage('build docker image') {
steps {
sh "pwd"
sh "ls -l"
sh "docker build -t dockerhub-image Dockerfile"
}
}
}
Please find the below output as well.
pwd --> output
/var/lib/jenkins/workspace/pipeline
ls -l
rw-r--r- 1 jenkins jenkins 11 Nov 24 06:26 Dockerfile
rw-r--r- 1 jenkins jenkins 46 Nov 24 04:57 README.md
rw-r--r- 1 jenkins jenkins 5970 Nov 24 04:57 pom.xml
########### docker build -t dockerhub-image Dockerfile ####
ERROR:: unable to prepare context: context must be a directory: /var/lib/jenkins/workspace/pipeline/Dockerfile
Can you please help me on this, I tried several times but not working.
I have used below command's as well to build the image, but same issue.
docker build -t dockerhub-image Dockerfile
docker build -t dockerhub-image .
docker build -t dockerhub-image -f Dockerfile
I tried to search in old issues in stack overflow, but everyone saying that check the Dockerfile is present or not and check the Dockerfile naming convention, but everything is fine.