@@ -168,12 +168,14 @@ if [[ -n ${CHECKS["mount-home"]} ]]; then
168168 fi
169169fi
170170
171+ # Use GHCR to avoid hitting Docker Hub rate limit
172+ nginx_image=" ghcr.io/stargz-containers/nginx:1.19-alpine-org"
173+ alpine_image=" ghcr.io/containerd/alpine:3.14.0"
174+
171175if [[ -n ${CHECKS["containerd-user"]} ]]; then
172176 INFO " Run a nginx container with port forwarding 127.0.0.1:8080"
173177 set -x
174178 limactl shell " $NAME " nerdctl info
175- # Use GHCR to avoid hitting Docker Hub rate limit
176- nginx_image=" ghcr.io/stargz-containers/nginx:1.19-alpine-org"
177179 limactl shell " $NAME " nerdctl pull --quiet ${nginx_image}
178180 limactl shell " $NAME " nerdctl run -d --name nginx -p 127.0.0.1:8080:80 ${nginx_image}
179181
@@ -189,7 +191,6 @@ if [[ -n ${CHECKS["containerd-user"]} ]]; then
189191 mkdir -p " $hometmp "
190192 defer " rm -rf \" $hometmp \" "
191193 set -x
192- alpine_image=" ghcr.io/containerd/alpine:3.14.0"
193194 limactl shell " $NAME " nerdctl pull --quiet ${alpine_image}
194195 echo " random-content-${RANDOM} " > " $hometmp /random"
195196 expected=" $( cat " $hometmp /random" ) "
@@ -219,6 +220,34 @@ if [[ -n ${CHECKS["port-forwards"]} ]]; then
219220 limactl shell " $NAME " sudo zypper in -y netcat-openbsd
220221 fi
221222 " ${scriptdir} /test-port-forwarding.pl" " ${NAME} "
223+
224+ if [[ -n ${CHECKS["containerd-user"]} || ${NAME} == " alpine" ]]; then
225+ INFO " Testing that 'nerdctl run' binds to 0.0.0.0 by default and is forwarded to the host"
226+ if [ " $( uname) " = " Darwin" ]; then
227+ # macOS runners seem to use `localhost` as the hostname, so the perl lookup just returns `127.0.0.1`
228+ hostip=$( system_profiler SPNetworkDataType -json | jq -r ' first(.SPNetworkDataType[] | select(.ip_address) | .ip_address) | first' )
229+ else
230+ hostip=$( perl -MSocket -MSys::Hostname -E ' say inet_ntoa(scalar gethostbyname(hostname()))' )
231+ fi
232+ if [ -n " ${hostip} " ]; then
233+ sudo=" "
234+ if [ " ${NAME} " = " alpine" ]; then
235+ arch=$( limactl info | jq -r .defaultTemplate.arch)
236+ nerdctl=$( limactl info | jq -r " .defaultTemplate.containerd.archives[] | select(.arch==\" $arch \" ).location" )
237+ curl -Lso nerdctl-full.tgz " ${nerdctl} "
238+ limactl shell " $NAME " sudo apk add containerd
239+ limactl shell " $NAME " sudo rc-service containerd start
240+ limactl shell " $NAME " sudo tar xzf " ${PWD} /nerdctl-full.tgz" -C /usr/local
241+ rm nerdctl-full.tgz
242+ sudo=" sudo"
243+ fi
244+ limactl shell " $NAME " $sudo nerdctl info
245+ limactl shell " $NAME " $sudo nerdctl pull --quiet ${nginx_image}
246+ limactl shell " $NAME " $sudo nerdctl run -d --name nginx -p 8888:80 ${nginx_image}
247+
248+ timeout 3m bash -euxc " until curl -f --retry 30 --retry-connrefused http://${hostip} :8888; do sleep 3; done"
249+ fi
250+ fi
222251 set +x
223252fi
224253
0 commit comments