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
.