hack: Fix TestOverlay* test failure in pkg/archive

The pkg/archive/archive_linux_test.go tests create a test archive
content in a temporary directory. This also includes device nodes (using
mknod).
Running these tests in Docker-in-Docker (dind) with systemd was failing
with "operation not permitted" because the rootfs is remounted with
`nodev`.

This change aligns `hack/dind-systemd` with `hack/dind` by
conditionally mounting a `tmpfs` on `/tmp` (with dev enabled),
to make the mknod work.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2025-03-21 18:20:56 +01:00
committed by Rob Murray
parent 454a7a7358
commit 8d9e3502ab
2 changed files with 9 additions and 0 deletions

View File

@@ -52,6 +52,8 @@ if [ -d /sys/kernel/security ] && ! mountpoint -q /sys/kernel/security; then
fi
# Mount /tmp (conditionally)
# /tmp must be 'exec,rw', and 'dev' to allow mknod to work for the
# pkg/archive/archive_linux_test.go tests.
if ! mountpoint -q /tmp; then
mount -t tmpfs none /tmp
fi

View File

@@ -19,6 +19,13 @@ if [ ! -t 0 ]; then
exit 1
fi
# Mount /tmp (conditionally)
# /tmp must be 'exec,rw', and 'dev' (defaults) to allow mknod to work for the
# pkg/archive/archive_linux_test.go tests.
if ! mountpoint -q /tmp; then
mount -t tmpfs none /tmp
fi
# Change mount propagation to shared, which SystemD PID 1 would normally do
# itself when started by the kernel. SystemD skips that when it detects it is
# running in a container.