Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker build Error checking context: 'can't stat '\\?\C:\Users\username\AppData\Local\Application Data''

Tags:

docker

build

docker build failed on windows 10,

After docker installed successfully, While building docker image using below command.

docker build -t drtuts:latest . Facing below issue. enter image description here

Kindly let me know if any one resolved same issue.

like image 958
Vijayaragavan Avatar asked Dec 22 '16 15:12

Vijayaragavan


People also ask

What is docker build context?

The docker build command builds Docker images from a Dockerfile and a “context”. A build's context is the set of files located in the specified PATH or URL . The build process can refer to any of the files in the context. For example, your build can use a COPY instruction to reference a file in the context.

Why does docker build take so long?

¶ If your Docker image builds takes a long time downloading dependencies, it's a good idea to check whether you're installing more than you need to. First, check if you might be downloading development dependencies which are not needed in your image at all.

Which of these is used to exclude things from docker build context?

dockerignore file and exclude it from the Docker build context. In fact, it is a common practice than you might have thought. This allows you not to expose the entire blueprint of your Docker application.

How do I put files outside docker's build context?

The best way to work around this is to specify the Dockerfile independently of the build context, using -f. For instance, this command will give the ADD command access to anything in your current directory. docker build -f docker-files/Dockerfile .


2 Answers

The problem is that the current user is not the owner of the directory.
I got the same problem in Ubuntu, this line solves the issue:

Ubuntu

sudo chown -R $USER <path-to-folder> 

Source: Change folder permissions and ownership

Windows

This link shows how to do the same in Windows:
Take Ownership of a File / Folder through Command Prompt in Windows 10

like image 138
Julian Avatar answered Oct 02 '22 14:10

Julian


Just create a new directory and enter it:

$ mkdir dockerfiles $ cd dockerfiles 

Create your file in that directory:

$ touch Dockerfile 

Edit it and add the commands with vi:

$ vi Dockerfile 

Fnally run it:

$ docker build -t tag . 
like image 37
nidal sarieddine Avatar answered Oct 02 '22 15:10

nidal sarieddine