diff --git a/integration/images/volume-copy-up/Dockerfile b/integration/images/volume-copy-up/Dockerfile index 24ce3f454..38471736a 100644 --- a/integration/images/volume-copy-up/Dockerfile +++ b/integration/images/volume-copy-up/Dockerfile @@ -16,4 +16,19 @@ ARG BASE FROM $BASE RUN sh -c "mkdir /test_dir; echo test_content > /test_dir/test_file" -VOLUME "/test_dir" +RUN sh -c "mkdir -p /C:/weird_test_dir; echo test_content > /C:/weird_test_dir/weird_test_file" +RUN sh -c "mkdir /:colon_prefixed; echo test_content > /:colon_prefixed/colon_prefixed_file" + +# We add a Windows style path here to ensure that for Linux, we don't mangle it in any way. +# The C: drive letter gets special treatment on Windows and is stripped by WithVolumes(). The remaining +# path is used to join with the volume mount point on the host. Colons are not allowed +# in Windows paths except when delimiting the drive letter, but on Linux such paths are +# perfectly valid and we must ensure we don't mutate them by accident. +# +# The C:/weird_test_dir volume is considered relative to "/" and will result in a mount point +# situated at /C:/weird_test_dir. +# +# The "/:colon_prefixed" volume is meant to test that we don't ignore copying existing contents +# to a volume containing a colon as the second character in the path on Linux, considering that +# on Windows, we skip this operation for any non-C volume defined here. +VOLUME ["/test_dir", "C:/weird_test_dir", "/:colon_prefixed"] diff --git a/integration/images/volume-copy-up/Dockerfile_windows b/integration/images/volume-copy-up/Dockerfile_windows index 5e57623f5..6299cbdb1 100644 --- a/integration/images/volume-copy-up/Dockerfile_windows +++ b/integration/images/volume-copy-up/Dockerfile_windows @@ -34,4 +34,10 @@ RUN mkdir C:\test_dir && \ /bin/sh.exe -c "echo test_content > /test_dir/test_file" ENV PATH="C:\bin;C:\Windows\System32;C:\Windows;" -VOLUME "C:/test_dir" + +# Add an extra volume under D: to test that WithVoumes() doesn't err out when dealing with +# a non-C volume in WCOW. +# +# See: +# https://github.com/containerd/containerd/issues/8171 +VOLUME ["C:/test_dir", "D:"] diff --git a/integration/images/volume-copy-up/Makefile b/integration/images/volume-copy-up/Makefile index cba817488..a77694f99 100644 --- a/integration/images/volume-copy-up/Makefile +++ b/integration/images/volume-copy-up/Makefile @@ -15,7 +15,7 @@ all: build PROJ=ghcr.io/containerd -VERSION=2.1 +VERSION=2.2 IMAGE=$(PROJ)/volume-copy-up:$(VERSION) DOCKER_CERT_PATH ?= "$(HOME)/.docker" REMOTE_DOCKER_URL ?=