Docker Community Forums

Share and learn in the Docker community.

What kind of context or pre-configuration is required before running "docker build" from command line?

The docker build is one of the most strange docker commands. Why? because it looks just simple but it’s failed almost the times running without correct context or pre-configuration (and this kind of context information is not documented at all).

I started running the first command docker build when working with a project with Docker support added (using Visual Studio). So the Package Manager Console there seems to be so powerful over some external (and standard) tools like CMD. Why? because it just makes the docker build run successfully (by applying all the knowledge in the documentation about it). However applying that same kind of knowledge to run docker build in CMD is simply failed with a very confusing message like this:

error checking context: 'can't stat '\\?\C:\Users\vhlpro\AppData\Local\ElevatedDiagnostics''

The Package Manager Console also just works in case there is some solution currently opened having at least one project with docker support added. That means opening Visual Studio without any solution and just using the Package Manager Console brings the same result with using CMD.

Here is my simple setup, I have just one Dockerfile placed in “D:”, so the following should work (following what documented):

docker build --force-rm -t myimage --file=D:\Dockerfile .

But it does not work, well so what’s the documentation for? It is useless in this case, isn’t it?

Actually I’ve never run docker build successfully manually using some external command line tool like CMD. It always requires a project opened (with docker support) and the integrated Package Manager Console tool.

It’s so weird. If it requires any context, please let me know what it is so that I can prepare a batch file to run first before I can run docker build successfully using CMD. Thank you (for helping me to run a perfectly-designed command - perfect even in how we run it).