@@ -168,12 +168,14 @@ if [[ -n ${CHECKS["mount-home"]} ]]; then
168
168
fi
169
169
fi
170
170
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
+
171
175
if [[ -n ${CHECKS["containerd-user"]} ]]; then
172
176
INFO " Run a nginx container with port forwarding 127.0.0.1:8080"
173
177
set -x
174
178
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"
177
179
limactl shell " $NAME " nerdctl pull --quiet ${nginx_image}
178
180
limactl shell " $NAME " nerdctl run -d --name nginx -p 127.0.0.1:8080:80 ${nginx_image}
179
181
@@ -189,7 +191,6 @@ if [[ -n ${CHECKS["containerd-user"]} ]]; then
189
191
mkdir -p " $hometmp "
190
192
defer " rm -rf \" $hometmp \" "
191
193
set -x
192
- alpine_image=" ghcr.io/containerd/alpine:3.14.0"
193
194
limactl shell " $NAME " nerdctl pull --quiet ${alpine_image}
194
195
echo " random-content-${RANDOM} " > " $hometmp /random"
195
196
expected=" $( cat " $hometmp /random" ) "
@@ -219,6 +220,34 @@ if [[ -n ${CHECKS["port-forwards"]} ]]; then
219
220
limactl shell " $NAME " sudo zypper in -y netcat-openbsd
220
221
fi
221
222
" ${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
222
251
set +x
223
252
fi
224
253
0 commit comments