docker image build "context canceled" error on windows 10

Viewed 12280

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
8 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.

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!

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

if you want to run docker build from Rstudio, please add a .dockerignore file containing :

.RData
.Rhistory
.git
.gitignore
manifest.json
rsconnect/
.Rproj.user

Got same error when tried to run docker-compose in Visual Studio with Release build. Change to Debug solved the problem.

Try with sudo in case you are on mac.

for windows users, disable 'metered connection' for you network.

I had this issue with docker.

For me it was a problem with my Hard Disk Drive.

My project was in one of my drives and I repeatedly got this error.

So I've moved my project to another drive and the problem gone.

I had some bad sectors.

Maybe this happens to you.

Related