Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker image build "context canceled" error on windows 10

Tags:

docker

windows

r

i'm trying to build a simple r-base official docker image but it's giving me a strange "context cancelled" error on windows 10.

i've tried pulling the image (which was successful) and then building it but i'm getting the same error. i've also tried reinstalling docker or building any other image (R or not) from Docker Hub but i'm having no luck with it as well. the strange thing is when i reinstalled docker, it ran the getting-started tutorial on shell without problems.

what may be happening?

here's my dockerfile

FROM r-base:4.0.2
COPY . /usr/local/src/myscripts
WORKDIR /usr/local/src/myscripts
CMD ["Rscript", "main.R"]

and the shell output

C:\Users\jean\path>docker build -t my-image .
[+] Building 1.7s (5/7)
 => [internal] load build definition from Dockerfile                                                               0.1s
 => => transferring dockerfile: 31B                                                                                0.0s
 => [internal] load .dockerignore                                                                                  0.1s
 => => transferring context: 2B                                                                                    0.0s
 => [internal] load metadata for docker.io/library/r-base:4.0.2                                                    1.4s
 => CANCELED [internal] load build context                                                                         0.1s
 => => transferring context: 7.08kB                                                                                0.0s
 => CANCELED [1/3] FROM docker.io/library/r-base:4.0.2@sha256:837898ed6a0dc6f9cb0f3d1fa0e801f01673797cdfd3e21c8cd  0.1s
 => => resolve docker.io/library/r-base:4.0.2@sha256:837898ed6a0dc6f9cb0f3d1fa0e801f01673797cdfd3e21c8cd2ad60f2db  0.0s
 => => sha256:837898ed6a0dc6f9cb0f3d1fa0e801f01673797cdfd3e21c8cd2ad60f2dbe2da 765B / 765B                         0.0s
 => => sha256:1c4e181b5dbeef804a4bf1f2c6b888b0d2da333b1a5d99f0e1a3ced46b1cdaef 1.58kB / 1.58kB                     0.0s
 => => sha256:673e45d6ffe13b98601b5e19ec2bfbd4ec1b1c135ed9d9e911f6c83c7b9cef1e 5.35kB / 5.35kB                     0.0s
error from sender: context canceled
like image 755
jean Avatar asked Dec 11 '20 02:12

jean


People also ask

Where are Dockerfiles stored Windows?

If you want to access the image data directly, it's usually stored in the following locations: Linux: /var/lib/docker/ Windows: C:ProgramDataDockerDesktop. macOS: ~/Library/Containers/com.

What is Docker Buildcontext?

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.

Where should I put Dockerfiles?

The best way is to put the Dockerfile inside the empty directory and then add only the application and configuration files required for building the docker image. To increase the build's performance, you can exclude files and directories by adding a . dockerignore file to that directory as well.


3 Answers

I ran across the same problem, and discovered the issue was with R/RStudio. I was running the docker build through the terminal pane and it kept giving me the "error from sender: context canceled" comment. I believe that R/RStudio locks up the files it is using, which throws a wrench into the docker machinery when it tries to copy the files. Docker built the image with no problem after I closed RStudio and ran the build through a different terminal.

like image 141
user15435859 Avatar answered Nov 10 '22 12:11

user15435859


I had the same problem when I was building the image with DOCKER. The problem is shown in the following image.

Docker build error

After that I closed RStudio, it worked!

like image 36
Oussama Errazi Avatar answered Nov 10 '22 11:11

Oussama Errazi


I had the same issue when running a Docker build from the RStudio Terminal. For me adding a Windows Firewall rule to allow the app "RStudio Session" fixed it. You can change it by Control Panel

Control Panel\System and Security\Windows Defender Firewall\Allowed apps

like image 45
ZealousDad Avatar answered Nov 10 '22 13:11

ZealousDad