12

My directory structure:

├── src/
├───── backend/
├─────── Dockerfile
├─────── ...
├───── frontend/
├─────── Dockerfile
├─────── node_modules/
├─────── ...
├───── commons/
├─────── ...
├── .dockerignore

.dockerignore includes the line **/node_modules and my build context is the root directory due to usage of commons.

I'm running both

docker build ... -f src/backend/Dockerfile .

docker build ... -f src/frontend/Dockerfile .

in parallel, and sometimes the backend build will fail on the following specific error:

error checking context: 'file ('/workspace/src/frontend/node_modules/.staging/wrap-ansi-2a6f888f') not found or excluded by .dockerignore'.

From my understanding (see Why do Node modules go into .staging folder?) the .staging folder is temporary and there might be a race condition when walking it (see Docker cli source).

However, why is this file walked in the first place if node_modules is ignored? Am I misusing the ignore context functionality or is it an actual race condition?

The issue is reproduced in Google Cloud Build environment, where I'm using docker cli via the image gcr.io/cloud-builders/docker, which uses docker client version 19.03.5 and is run with docker server version 18.09.3, API version 1.39.

Mugen
  • 8,301
  • 10
  • 62
  • 140
  • 2
    first, are both the backend and frontend services use JS? second, please add your Dockerfile so we could get more context to the Dockerfile running process – Noam Yizraeli Sep 10 '21 at 16:41

1 Answers1

0

Clean your system.

docker system prune -a

Note this will remove also all images not used in a container.

Ralle Mc Black
  • 1,065
  • 1
  • 8
  • 16