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. Kindly let me know if any one resolved same issue.
1 1 1 silver badge asked Dec 22, 2016 at 15:01 Vijayaragavan Vijayaragavan 949 1 1 gold badge 9 9 silver badges 8 8 bronze badges Can you add your Dockerfile. Commented Dec 23, 2016 at 5:54 Were you able to solve the problem . I am facing the same issue Commented Feb 27, 2017 at 6:36The 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
Windows
33.3k 6 6 gold badges 44 44 silver badges 62 62 bronze badges answered May 26, 2020 at 4:53 Julian Espinel Julian Espinel 3,322 5 5 gold badges 29 29 silver badges 23 23 bronze badgesthis is a "quick fix", but Quinten's answer below goes into more detail and solves the actual problem.
Commented Jan 6, 2023 at 22:33When you run the docker build command, the Docker client gathers all files that need to be sent to the Docker daemon, so it can build the image. This 'package' of files is called the context.
What files and directories are added to the context?
The context contains all files and subdirectories in the directory that you pass to the docker build command. For example, when you call docker build img:tag dir_to_build , the context will be everything inside dir_to_build .
If the Docker client does not have sufficient permissions to read some of the files in the context, you get the error checking context: 'can't stat ' error.
There are two solutions to this problem:
Before the docker CLI sends the context to the docker daemon, it looks for a file named .dockerignore in the root directory of the context. If this file exists, the CLI modifies the context to exclude files and directories that match patterns in it.
I would create a .dockerignore file in the same directory as the Dockerfile : ~/.dockerignore with the following contents:
# By default, ignore everything * # Add exception for the directories you actually want to include in the context !project-source-code !project-config-dir # source files !*.py !*.sh
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
$ docker build -t tag .
4,335 3 3 gold badges 23 23 silver badges 29 29 bronze badges
answered Dec 31, 2016 at 15:26
nidal sarieddine nidal sarieddine
489 3 3 silver badges 2 2 bronze badges
The problem is for docker running on windows container not linux
Commented Feb 27, 2017 at 6:37
Question is why? Why works in /c/Users/myuser/dockerfiles but not /c/Users/myuser
Commented Feb 21, 2019 at 19:37
Added dot per stackoverflow.com/questions/28996907/….
Commented Oct 8, 2019 at 21:15
worked on mac ! Thought it was permissions issue. thanks
Commented Nov 2, 2019 at 0:16
Docker grants read and write rights to only to the owner of the file, and sometimes the error will be thrown if the user trying to build is different from the owner.
You could create a docker group and add the users there. in debian would be as follows
sudo groupadd docker
sudo usermod -aG docker $USER
answered Aug 15, 2018 at 15:51 Brian Phiri Brian Phiri 154 2 2 silver badges 12 12 bronze badgesI was also getting the same error message on Windows 10 Home version.
I resolved it by the following steps:
Now run the command : docker build -t ./dockerfiles
It worked like a breeze!
answered Jun 25, 2017 at 6:29 Piyush Bhattacharya Piyush Bhattacharya 63 1 1 silver badge 5 5 bronze badgesI was having the same issue but working with Linux
$ docker build -t foramontano/openldap-schema:0.1.0 --rm . $ error checking context: 'can't stat '/home/isidoronm/foramontano/openldap_docker/.docker/config/cn=config''.
I was able to solve the problem with the issue. by including the directory referred in the log (/home/isidoronm/foramontano/openldap_docker/.docker) inside the .dockerignore file located in the directory i have the Dockerfile file.(/home/isidoronm/foramontano/openldap_docker )
isidoronm@vps811154:~/foramontano/openldap_docker$ ls -al total 48 drwxrwxr-x 5 isidoronm isidoronm 4096 Jun 16 18:04 . drwxrwxr-x 9 isidoronm isidoronm 4096 Jun 15 17:01 .. drwxrwxr-x 4 isidoronm isidoronm 4096 Jun 16 17:08 .docker -rw-rw-r-- 1 isidoronm isidoronm 43 Jun 13 17:25 .dockerignore -rw-rw-r-- 1 isidoronm isidoronm 214 Jun 9 22:04 .env drwxrwxr-x 8 isidoronm isidoronm 4096 Jun 13 17:37 .git -rw-rw-r-- 1 isidoronm isidoronm 5 Jun 13 17:25 .gitignore -rw-rw-r-- 1 isidoronm isidoronm 408 Jun 16 18:03 Dockerfile -rw-rw-r-- 1 isidoronm isidoronm 1106 Jun 16 17:10 Makefile -rw-rw-r-- 1 isidoronm isidoronm 18 Jun 13 17:36 README.md -rw-rw-r-- 1 isidoronm isidoronm 1877 Jun 12 12:11 docker-compose.yaml drwxrwxr-x 3 isidoronm isidoronm 4096 Jun 13 10:51 service
Maybe it's valid something similar in Windows 10.