Open kit-ty-kate opened 4 years ago
What version/software this is?
Client: Docker Engine - Community
Version: 19.03.8
API version: 1.40
Go version: go1.12.17
Git commit: afacb8b7f0
Built: Wed Mar 11 01:25:56 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.8
API version: 1.40 (minimum version 1.12)
Go version: go1.12.17
Git commit: afacb8b7f0
Built: Wed Mar 11 01:24:28 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
We see this sporadically in our CI pipeline -- we have make
kick off several parallel builds and every once in a while the job will fail with the "mount already exists with name"
error:
#8 [build 2/4] WORKDIR /src/api
#8 ERROR: mount already exists with name
#9 [internal] load build context
#9 transferring context: 7.09MB 0.1s done
#9 CANCELED
------
> [build 2/4] WORKDIR /src/api:
------
failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0: rpc error: code = Unknown desc = failed to build LLB: mount already exists with name
Makefile:309: recipe for target 'docker-build-swagger' failed
make: *** [docker-build-swagger] Error 1
make: *** Waiting for unfinished jobs....
Could it be because the stages are aliased with the same name? The Dockerfile
's that are built at that time both have statements like:
FROM <our-common-build-image>:latest AS build
FYI we hit this on docker:20.10.2. We kick off two builds using the same docker-dind service using K8s on GitLab CI. Those builds have lots of similarities, including overlapping build stage names.
We see this in CI as well when using make to parallelize multiple multistage builds that all have the same FROM imagename as builder
. I'm wondering if @dotcarls might be on to something.
Yeah we just hit this too:
#9 [stage-1 2/4] COPY --chown=atcloud:atcloud .npmrc package.json /usr/local/autotrader/app/
#9 sha256:be4cfa891678f62a7c246fdab682b5253f37aeb2b9b4b0c0640aa38d3fff47c2
#9 ERROR: mount already exists with name
------
> [build 2/6] COPY --chown=atcloud:atcloud package.json .npmrc /usr/local/autotrader/app/:
------
------
> [stage-1 2/4] COPY --chown=atcloud:atcloud .npmrc package.json /usr/local/autotrader/app/:
------
mount already exists with name
Service 'app' failed to build : Build failed
your build failed! check the logs above to understand the reason, you can recreate locally by running 'docker-compose build'
Two layers from separate stages copying files from the host, and similar to the above, both of our layers are FROM
the same image.
bash-5.1# docker version
Client:
Version: 20.10.8
API version: 1.41
Go version: go1.16.6
Git commit: 3967b7d
Built: Fri Jul 30 19:50:40 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.8
API version: 1.41 (minimum version 1.12)
Go version: go1.16.6
Git commit: 75249d8
Built: Fri Jul 30 19:55:09 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.4.9
GitCommit: e25210fe30a0a703442421b0f60afac609f950a3
runc:
Version: 1.0.1
GitCommit: v1.0.1-0-g4144b638
docker-init:
Version: 0.19.0
GitCommit: de40ad0
We see this in CI as well when using make to parallelize multiple multistage builds that all have the same
FROM imagename as builder
. I'm wondering if @dotcarls might be on to something.
This seems to be a dead end. We renamed our multistage names to be unique for each parallelized (ie. FROM image name as builder_for_app1
, FROM imagename as builder_for_app2
, etc.) and still saw this issue.
Seeing this with Docker version 20.10.11
, on a gitlab-runner host for CI pipeline.
How can we investigate to understand what's going on?
We also see this problem with docker 23.01. It appears when we run 2 simultaneous docker build commands with the same FROM image and the same layers up to the first of the COPY commands, like in the example of user Stono at https://github.com/moby/buildkit/issues/1460#issuecomment-938536403
We were able to fix this by building with "--no-cache", accepting the downsides of this approach.
This leads to the following hypothesis on the root cause:
FROM myimage:mytag
COPY a/ /a/
COPY b/ /b/
Looking through the code where this error could occur, the only place this occurs is here:
This has 2 callers (for build): https://github.com/moby/moby/blob/f00569b89154a5ce8c290d5420019bb20a8ab632/builder/builder-next/adapters/snapshot/snapshot.go#L280-L285
The "name" here is always a random ID generated by crypto/rand
.
With a similar Dockerfile to https://github.com/moby/buildkit/issues/1459#issuecomment-618690727:
our docker build sometimes fails with:
I've tried several hours to get a minimal test-case without success, however it still happens pretty often on our test server.
Here is our daemon log: