dockerdockerfiledocker-build

Docker Build Command Results in File Not Found Error


I try to run:

docker build --build-arg JAR_FILE=target/*.jar -t myapp -f .\Dockerfile .

And I get the error:

ERROR: failed to solve: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount2423436051/.Dockerfile: no such file or directory

I went online and the blog posts suggested to name the docker file Dockerfile, which I believe that I have done.

What is wrong with this command?

I ran the command and I got that error.

UPDATE: I updated the command to: docker build --build-arg JAR_FILE=target/*.jar -t myapp . but I still get the error. Below are the files/folders in my current directory:

/var/lib/docker/tmp/buildkit-mount3815898823/Dockerfile: no such file or directory

README.adoc             mvnw                    node_modules            package.json            src                     webpack.config.js
images                  mvnw.cmd                package-lock.json       pom.xml                 target

Solution

  • You don't have to specify Dockerfile, instead do:

    cd /where/is/Dockerfile
    docker build --build-arg JAR_FILE=target/*.jar -t myapp .
    

    Only use -f with different names of files than Dockerfile.