A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/opencontainers/runc/issues/4543 below:

Starting parallel containers with same mounts can cause an error · Issue #4543 · opencontainers/runc · GitHub

Description

When starting a container, runc will create destination paths for mountpoints. If there is another process creating the same paths at the same time then this step can fail with mkdir failing with EEXIST and container failing to start.

This race can happen if the paths getting mounted get modified externally, but it can also happen when just two runc processes are started at the same time and they compete with each other when creating the mountpoints.

I didn't look too deeply, but looks like a bug in mkdirp logic where it could just verify that the path already exists after it receives this error.

Reported via moby/buildkit#5566

Steps to reproduce the issue

This Dockerfile+script demonstrates the issue. I couldn't repro locally, but reproduces quite reliably (<20 iterations) in Github codespaces.

FROM alpine AS b1
RUN --mount=type=cache,target=/foo/bar --mount=type=cache,target=/foo/bar/baz echo 1

FROM alpine AS b2
RUN --mount=type=cache,target=/foo/bar --mount=type=cache,target=/foo/bar/baz echo 2

FROM scratch
COPY --from=b1 /etc/passwd p1
COPY --from=b2 /etc/passwd p2
#!/usr/bin/env bash

set -ex

for i in $(seq 1 100); do
docker buildx build --no-cache .
done

Note that in this Dockerfile, the paths for type=cache mounts are shared between stages. So /foo/bar points to same directory in both and failure happens when two runc processes both try to create /foo/bar/baz under it.

Describe the results you received and expected
 => ERROR [b2 2/2] RUN --mount=type=cache,target=/foo/bar --mount=type=cache,target=/foo/bar/baz echo 2                                   0.3s
------                                                                                                                                         
 > [b2 2/2] RUN --mount=type=cache,target=/foo/bar --mount=type=cache,target=/foo/bar/baz echo 2:                                              
0.275 runc run failed: unable to start container process: error during container init: error mounting "/var/lib/docker/overlay2/k72e3l8s3aw1xwilhrtrirlug/diff" to rootfs at "/foo/bar/baz": create mount destination for /foo/bar/baz mount: mkdirat /var/lib/docker/buildkit/executor/sjac66hcl5qvqkt3xav7q855m/rootfs/foo/bar/baz: file exists
------
Dockerfile:5
--------------------
   3 |     
   4 |     FROM alpine AS b2
   5 | >>> RUN --mount=type=cache,target=/foo/bar --mount=type=cache,target=/foo/bar/baz echo 2
   6 |     
   7 |     FROM scratch
--------------------
ERROR: failed to solve: process "/bin/sh -c echo 2" did not complete successfully: exit code: 1
What version of runc are you using?

1.1.14 and 1.2.2 in codespaces

Host OS information

No response

Host kernel information

No response


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4