I'm running :

$ docker build -t somefile .

Every time I run that I get this error:

unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat 

The full error is:

unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/someusername/code/Dockerfile: no such file or directory

I thought this had to do with the docker version I'm using, so upgraded to the latest version using this guide: Install Latest docker version. I still get the same error. I've tried different docker versions. I've tried on different servers. I've even tried different docker files.

The last server I tried on I was using this version of docker:

Docker version 17.03.1-ce, build c6d412e

Not sure where I'm going wrong. Need a sanity check please.

  • Error is very clear. lstat /home/someusername/code/Dockerfile: no such file or directory did you check that file? Jun 18, 2017 at 19:21
  • 1
    Turns out I was not naming my file "Dockerfile". Jun 19, 2017 at 5:52
  • 1
    I found out if I want to use a name other than "Dockerfile" for a dockerfile I can use: ` docker build -f /path/to/a/Dockerfile .` Jun 19, 2017 at 5:52

3 Answers 3


I see this question being asked at a number of places. Well I think I found the solution.

In earlier versions, the DockerFile was named with a capital 'F'. However in the latest releases, the DockerFile is recognized only if contains a small 'f'.

I recently upgraded the docker [Docker version 17.09.1-ce, build 19e2cf6 on CentOS 7] and found that

docker build -t someapp .

Fails if the current directory contains the file DockerFile, but works well if it contains Dockerfile

  • OMG such a minor stupid thing. Thanks for pointing it out.
    – Thanos
    Sep 9, 2019 at 12:20
  • Saved my too thx.
    – Mellester
    Jun 15 at 9:06

In your current directory run command "ls" and see what file extension is with Dockerfile. If you have an extension you need to specify the full path to the Dockerfile.abc

Else you can create a blank Dockerfile WITHOUT an extension using "TextWrangler" (available for mac) and then run the command

docker image build -t yourname/firstapp .

I hope you have already resolved the issue; sharing this for future visitors :) attached is the terminal screenshot with solution

enter image description here


Try the following syntax for building the docker image using docker build, on docker version 20.10.5, build 55c4c88, on Ubuntu 20.0.4 LTS-March 2021:

$ docker build -t <containername> . -f <whateverthedockerfilename>.Dockerfile


Whenever your're using the command 'docker build', if you do not explicitly specify the dockerfile name from which you want to build your docker image, then, by default, the docker engine will start looking for a Dockerfile with the default name 'Dockerfile.Dockerfile' in your original working directory, instead of looking for any Dockerfile with the extension '.Dockerfile'.

Therefore, in such cases, whenever the docker engine cannot locate the file 'Dockerfile.Dockerfile', it will understandably throw the error "unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/xxx/yyy/Dockerfile: no such file or directory."

So to get things running, you just need to specify the correct name of your dockerfile as labelled in your original directory and BAM IT SHOULD WORK! 🐱‍💻


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .