solution to this exact problem is commented below.
original problem: when try to buildup a docker container and using nerdctl inside it, an error occurs:
failed to create shim task: failed to mount rootfs component: invalid argument: unknown.
So, main question is; how to work this out???
I see containerd/runtime/v2/manager.go, but no idea of why cause rootfs component mount err.

To reproduce the issue: clone nerdctl & compile it using:
cd ${dir_of_nerdctl} && make all
maintain a dockerfile at the same dir level of nerdctl like:
FROM alpine:3.18
# ENV http_proxy='http://xxxx:8080'
# ENV https_proxy='http://xxxx:8080'
RUN apk update && \
apk add --no-cache vim && \
apk add --no-cache make && \
apk add --no-cache go && \
apk add --no-cache git && \
apk add --no-cache containerd && \
apk add --no-cache openrc && \
apk add --no-cache cni-plugins && \
rm -rf /var/cache/apk/*
VOLUME [ "/sys/fs/cgroup" ]
COPY ./s0_entry.sh /scripts/s0_entry.sh
ENTRYPOINT ["/scripts/s0_entry.sh"]
s0_entry.sh
#!/bin/sh
. /scripts/logger.sh
prepare_nerdctl_binary() {
nerdctl='/nerdctl/_output/nerdctl'
if [ -f "${nerdctl}" ]; then
ln -s "${nerdctl}" /usr/local/bin/nerdctl
echo 'nerdctl binary add to path'
else
echo 'no binary executable nerdctl found under /nerdctl/_outputs'
exit 1
fi
}
startup_containerd_openrc() {
# init
rc-status
touch /run/openrc/softlevel
# config
rc-update add containerd default
# start
rc-service containerd start
rc-service containerd status
echo 'containerd started'
}
start() {
nerdctl ps -a
echo 'nerdctl started'
}
echo "$0 running"
prepare_nerdctl_binary
startup_containerd_openrc
echo "$0 finsihed"
exec "$@"
cmd to buildup docker image:
docker build -t nerdctl:test .
cmd to enter alpine container:
scriptpath="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
docker run -it --rm -v "$scriptpath"/nerdctl:/nerdctl --privileged --cap-add all nerdctl:test sh
try startup another alpine container with nerdctl inside:
nerdctl run -it --rm alpine:latest sh
the error like the title claim occur.