Not able to use a Dockerfile when using Jenkins CloudBees Docker Custom Build Environment Plugin Not able to use a Dockerfile when using Jenkins CloudBees Docker Custom Build Environment Plugin jenkins jenkins

Not able to use a Dockerfile when using Jenkins CloudBees Docker Custom Build Environment Plugin


I guess finally got the answer !

I just had the very same problem as you do right now, and it is actually very silly.

I assume you have ticked "build inside a Docker container" in the project configuration page. You must also have specified a path in which you made sure that a Dockerfile was inside the repository.

This is the point. If there is a Dockerfile inside this path, the writing space next to "Dockerfile" must be left blank. I guess this space consists in using a Dockerfile which is not inside the specified path. Without this, Jenkins will assume your Dockerfile is inside your specified space, and it will not bother considering any other location.

Since I am new to StackOverflow, I cannot post any screenshot yet. But when I can, I will make sure you have it so I can make my point more easily.

I sincerely hope this will help. I had the same type of error message at the output, and now I can build my Docker images without any trouble.


If you're currently in the directory with the Dockerfile, the following should work:

$ docker build --tag b916af9f0b3e48425cb54c323d1a3adb749a72a1 --file Dockerfile .

Which is equivalent to:

$ docker build --tag b916af9f0b3e48425cb54c323d1a3adb749a72a1 .

In both cases the . specifies the build context - the set of directories and files that get sent to the Docker daemon. Using . simply sets it to the current directory. As the Dockerfile is in the current directory, it will be sent to the daemon.

The problem in your example is that it is looking for the Dockerfile at /var/lib/jenkins/jobs/lumi/workspace/Dockerfile. Presumably, the Dockerfile isn't there, but in your current directory. As only the files in the directory /var/lib/jenkins/jobs/lumi/workspace were sent to the Docker daemon, it doesn't have your Dockerfile to build with.

I realise this sounds a bit strange. Until it makes more sense, it's easiest just to run your builds from the directory with the Dockerfile to avoid problems like this.

(Also, don't put your Dockerfile in your home directory or your Downloads folder as it will result in a long wait as all the data is sent to the daemon).


Assuming that you are running this setup on Jenkins slave machine.

enter image description here

${WORKSPACE} will set the docker context. This should solve your path issues.