CANCELED [frontend internal] load build context

I have a MERN stack app that I am working on. Whenever I run docker-compose --verbose up --build , it builds an image for Mongo and the backend just fine. However, it hangs up on the frontend with the error CANCELED [frontend internal] load build context .

The full message on the console is this:

PS C:\Users\autum\OneDrive\CODE\WEB\Vidly> docker-compose --verbose up --build
time="2023-10-07T11:10:49-07:00" level=debug msg="using default config store \"C:\\\\Users\\\\autum\\\\.docker\\\\buildx\""
[+] Building 2.8s (12/12)                                                                                                                    docker:default
[+] Building 4.7s (15/18)                                                                                                                    docker:default
 => [backend internal] load build definition from dockerfile                                                                                           0.1s 
 => => transferring dockerfile: 598B                                                                                                                   0.0s 
 => [backend internal] load .dockerignore                                                                                                              0.0s
 => => transferring context: 2B                                                                                                                        0.0s 
 => [frontend internal] load metadata for docker.io/library/node:14.16.0-alpine3.13                                                                    1.6s
 => [backend auth] library/node:pull token for registry-1.docker.io                                                                                    0.0s
 => [frontend 1/6] FROM docker.io/library/node:14.16.0-alpine3.13@sha256:2c51dc462a02f15621e7486774d36d048a27225d581374b002b8477a79a59b4b              0.0s 
 => [backend internal] load build context                                                                                                              1.3s 
 => => transferring context: 192.43kB                                                                                                                  1.3s
 => CACHED [backend 2/6] RUN addgroup app && adduser -S -G app app                                                                                     0.0s 
 => CACHED [backend 3/6] WORKDIR /app                                                                                                                  0.0s 
 => CACHED [backend 4/6] COPY package*.json ./                                                                                                         0.0s 
 => CACHED [backend 5/6] RUN npm install                                                                                                               0.0s 
 => CACHED [backend 6/6] COPY . .                                                                                                                      0.0s 
 => [backend] exporting to image                                                                                                                       0.0s 
 => => exporting layers                                                                                                                                0.0s 
 => => writing image sha256:6b403109fcae4c4a19181b7375a22fd1f422ff00cd2f7d9fb5016cd7e71cc505                                                           0.0s 
 => => naming to docker.io/library/vidly-backend                                                                                                       0.0s
 => [frontend internal] load build definition from dockerfile                                                                                          0.4s
 => => transferring dockerfile: 659B                                                                                                                   0.0s 
 => [frontend internal] load .dockerignore                                                                                                             0.3s
 => => transferring context: 2B                                                                                                                        0.0s 
 => CANCELED [frontend internal] load build context                                                                                                    0.5s 
 => => transferring context: 1.85MB                                                                                                                    0.4s 
time="2023-10-07T11:10:49-07:00" level=debug msg="using default config store \"C:\\\\Users\\\\autum\\\\.docker\\\\buildx\""
time="2023-10-07T11:10:51-07:00" level=debug msg="serving grpc connection"
time="2023-10-07T11:10:51-07:00" level=debug msg="stopping session" span="load buildkit capabilities"
time="2023-10-07T11:10:52-07:00" level=debug msg="serving grpc connection"
time="2023-10-07T11:10:55-07:00" level=debug msg="stopping session"
time="2023-10-07T11:10:55-07:00" level=debug msg="using default config store \"C:\\\\Users\\\\autum\\\\.docker\\\\buildx\""
time="2023-10-07T11:10:55-07:00" level=debug msg="stopping session" span="load buildkit capabilities"
time="2023-10-07T11:10:55-07:00" level=debug msg="serving grpc connection"
time="2023-10-07T11:10:55-07:00" level=debug msg="serving grpc connection"
time="2023-10-07T11:10:56-07:00" level=debug msg="stopping session"
failed to solve: Canceled: context canceled

Itā€™s worth noting that I pushed the whole project to a git repository so that someone else could try it on another computer. It builds and runs just fine on a mac, and it builds and runs just fine on my Windows desktop PC. It only seems to be having this problem on my Windows laptop (where it has worked before)

I also vaguely remember accidentally typing docker images trim or something like that because I forgot that it was prune and not trim for dangling images.

It also seems to build without errors using docker build . inside the frontend folder, but in the images list it shows up as dangling (repository and tag are set to <none>)

What I have tried:

  • deleting and reinstalling docker engine
  • switching contexts (I have tried default, desktop-linux, and desktop-windows)
  • deleting all images and volumes and building again
  • clean/purge data in docker desktop debug options
  • reset to factory defaults in docker desktop debug options
  • restarting my PC
  • restarting docker desktop

Any help or suggestions are welcome! I really enjoy working on my laptop so it would be great if the fix wasnā€™t ā€œwork on your desktop since it works thereā€.

That canā€™t be a problem as that is not a valid subcommand.

Itā€™s none, because you need to add a tag

docker build . -t whatever_tag_you_want

So it seems the problem is Docker Compose since you can build the image without it. Have you tried without the verbose option? I guess that was the first you did before using it, but I still have to ask.

How long it takes to build the image without Docker Compose? Can it be some kind of timeout behind the scenes or is it cancelled almost immediately?

Thank you for taking the time to respond to my issue.

  • After further inspection, the image is built just fine when I run docker build . in the frontend directory. I was confused because the other images that were build through docker-compose up --build have names. I can run the unnamed container using docker run <container_id_here> without any issue.

  • Yes, I have tried building without the verbose option, same problem occurs. I was hoping that the verbose option would give enough additional information to identify the source of the problem.

  • Without docker compose, it takes an EXTREMELY long time to build (up to 10 minutes). Itā€™s not a timeout because the time it takes to build varies each time I try, and it always fails with the same message on the same step. It never cancels immediately.

What is your Docker Desktop version?

Than my second guess is a memory issue even though Docker Compose is practically just another client for the docker API, it could do something that uses more memory and crashes randomly depending on how much memory your machine uses at that time. There is nothing indicating that, but I donā€™t really know the reason so Iā€™m guessing.

I am having the same issue on Windows suddenly too:

>>> docker-compose --verbose -f docker-compose.yml -f docker-compose-dev.yml up
[+] Running 1/1
 ! app Warning                                                                                                                                                                                                                                                                                                                                       2.2s
time="2023-10-20T15:45:35+02:00" level=debug msg="using default config store \"C:\\\\Users\\\\Oisin\\\\.docker\\\\buildx\""
[+] Building 1.4s (5/19)                                                                                                                                                                                                                                                                                                                   docker:default
 => [app internal] load .dockerignore                                                                                                                                                                                                                                                                                                                0.0s
 => => transferring context: 65B                                                                                                                                                                                                                                                                                                                     0.0s
 => [app internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                                             0.0s
 => => transferring dockerfile: 1.16kB                                                                                                                                                                                                                                                                                                               0.0s
 => [app internal] load metadata for docker.io/library/python:3.9-buster                                                                                                                                                                                                                                                                             1.1s
 => CANCELED [app  1/15] FROM docker.io/library/python:3.9-buster@sha256:bae5b428ebf32d01a902718b0a58874cbf33d7a4b6a65b7cd7b21d48b0d2e2f1                                                                                                                                                                                                            0.1s
 => => resolve docker.io/library/python:3.9-buster@sha256:bae5b428ebf32d01a902718b0a58874cbf33d7a4b6a65b7cd7b21d48b0d2e2f1                                                                                                                                                                                                                           0.1s
 => => sha256:bae5b428ebf32d01a902718b0a58874cbf33d7a4b6a65b7cd7b21d48b0d2e2f1 988B / 988B                                                                                                                                                                                                                                                           0.0s
 => => sha256:191a38be55f72871359ebb522ab9621b872e67cac9b4b1834ccf1d2bce3a749d 2.01kB / 2.01kB                                                                                                                                                                                                                                                       0.0s
 => => sha256:2646d4308aee325505bf575b2ecbafb8ef5088d6727585cb6e8215a1534b2472 7.51kB / 7.51kB                                                                                                                                                                                                                                                       0.0s
 => CANCELED [app internal] load build context                                                                                                                                                                                                                                                                                                       0.1s
 => => transferring context: 4.60MB                                                                                                                                                                                                                                                                                                                  0.1s
time="2023-10-20T15:45:35+02:00" level=debug msg="using default config store \"C:\\\\Users\\\\Oisin\\\\.docker\\\\buildx\""
time="2023-10-20T15:45:35+02:00" level=debug msg="serving grpc connection"
time="2023-10-20T15:45:35+02:00" level=debug msg="stopping session" span="load buildkit capabilities"
time="2023-10-20T15:45:35+02:00" level=debug msg="serving grpc connection"
time="2023-10-20T15:45:36+02:00" level=debug msg="stopping session"
failed to solve: Canceled: context canceled

Iā€™m having this problem suddenly too. Windows 11, latest updates, running Docker v4.24.2.

$ docker-compose --verbose build
time="2023-10-24T11:55:49-04:00" level=debug msg="using default config store \"C:\\\\Users\\\\jziss\\\\.docker\\\\buildx\""
[+] Building 1.0s (6/12)                                                                                                                                                       docker:default
 => [app internal] load build definition from Dockerfile                                                                                                                                 0.0s
 => => transferring dockerfile: 636B                                                                                                                                                     0.0s 
 => [app internal] load metadata for docker.io/library/node:18.18-alpine                                                                                                                 0.3s 
 => [app internal] load .dockerignore                                                                                                                                                    0.0s
 => => transferring context: 2B                                                                                                                                                          0.0s 
 => CACHED [app 1/8] FROM docker.io/library/node:18.18-alpine@sha256:435dcad253bb5b7f347ebc69c8cc52de7c912eb7241098b920f2fc2d7843183d                                                    0.0s 
 => => resolve docker.io/library/node:18.18-alpine@sha256:435dcad253bb5b7f347ebc69c8cc52de7c912eb7241098b920f2fc2d7843183d                                                               0.0s 
 => CANCELED [app internal] load build context                                                                                                                                           0.6s 
 => => transferring context: 60.01MB                                                                                                                                                     0.5s 
 => CANCELED [app 2/8] RUN apk add -u --no-cache chromium git                                                                                                                            0.0s
time="2023-10-24T11:55:49-04:00" level=debug msg="using default config store \"C:\\\\Users\\\\jziss\\\\.docker\\\\buildx\""
time="2023-10-24T11:55:49-04:00" level=debug msg="serving grpc connection"
time="2023-10-24T11:55:49-04:00" level=debug msg="stopping session" span="load buildkit capabilities"
time="2023-10-24T11:55:49-04:00" level=debug msg="serving grpc connection"
time="2023-10-24T11:55:50-04:00" level=debug msg="stopping session"
failed to solve: Canceled: context canceled

I was able to solve this issue by checking out my project into another folder; after doing so, docker compose build worked.

Seems a permissions issue might be part of the problem?

Sounds plausible. I fixed the issue, by deleting a node_modules folder that was copied into the image during the build. No idea why that was the issue.

1 Like

Add node_modules to .dockerignore