Docker Error — unable to prepare context: unable to evaluate symlinks in Dockerfile path: GetFileAttributesEx

When building a Docker image, you might encounter the following error:

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

This error typically appears when you run a command like:

docker build -t myapp .

or:

docker build -t myapp -f ./Dockerfile .

🔍 What This Error Means

The message GetFileAttributesEx comes from Windows APIs, indicating that Docker cannot read the specified Dockerfile path. This usually happens when:

  • The Dockerfile does not exist at the given location.
  • The file path is incorrect or malformed.
  • You’re using symbolic links (symlinks) that are broken or inaccessible.
  • Docker is being run from a different directory than you expect.

🛠 Common Causes and Fixes

1. Check the Dockerfile Path

Make sure your Dockerfile exists and the path is correct.

dir

You should see Dockerfile in the output. If it’s named differently (e.g., dockerfile in lowercase), rename it:

ren dockerfile Dockerfile

If you’re specifying a custom file:

docker build -f ./path/to/Dockerfile .

Ensure the path is relative to your current working directory.


2. Avoid Broken Symlinks

If you’re using symbolic links, confirm they’re valid:

dir /aL

If the link target is missing, recreate it:

mklink /H Dockerfile path\to\real\Dockerfile

3. Run the Command from the Correct Directory

If your Dockerfile is in a subfolder:

cd path\to\folder
docker build -t myapp .

or specify the full path:

docker build -f C:\full\path\to\Dockerfile .

4. Check for Hidden Extensions

Windows may hide known file extensions. Your file might be Dockerfile.txt without you realizing it.
To fix:

  • Open File Explorer.
  • Enable View → File name extensions.
  • Rename the file to Dockerfile.

5. Permissions Issue

If the file exists but is unreadable by Docker:

  • Right-click the file → PropertiesSecurity.
  • Make sure your user has read permissions.

✅ Example of Correct Usage

Correct:

docker build -t myapp -f ./Dockerfile .

Incorrect:

docker build -t myapp -f Dockerfile.txt .

(Unless you explicitly renamed it and updated the file path.)


📌 Summary

The unable to evaluate symlinks error means Docker can’t find or read your Dockerfile.
Checklist to fix:

  1. Verify the file exists and is named Dockerfile.
  2. Use the correct build context and working directory.
  3. Avoid broken symlinks.
  4. Check file extensions and permissions.
Sharing Is Caring:

Leave a Comment