@@ -436,6 +436,39 @@ function install-docker {
436
436
rm -rf /var/lib/apt/lists/*
437
437
}
438
438
439
+ # If we are on ubuntu we can try to install containerd
440
+ function install-containerd {
441
+ # bailout if we are not on ubuntu
442
+ if ! command -v apt-get > /dev/null 2>&1 ; then
443
+ echo " Unable to install automatically install docker. Bailing out..."
444
+ return
445
+ fi
446
+ # Install dependencies, some of these are already installed in the image but
447
+ # that's fine since they won't re-install and we can reuse the code below
448
+ # for another image someday.
449
+ apt-get update
450
+ apt-get install -y --no-install-recommends \
451
+ apt-transport-https \
452
+ ca-certificates \
453
+ socat \
454
+ curl \
455
+ gnupg2 \
456
+ software-properties-common \
457
+ lsb-release
458
+
459
+ # Add the Docker apt-repository (as we install containerd from there)
460
+ curl -fsSL https://download.docker.com/linux/$( . /etc/os-release; echo " $ID " ) /gpg \
461
+ | apt-key add -
462
+ add-apt-repository \
463
+ " deb [arch=amd64] https://download.docker.com/linux/$( . /etc/os-release; echo " $ID " ) \
464
+ $( lsb_release -cs) stable"
465
+
466
+ # Install containerd from Docker repo
467
+ apt-get update && \
468
+ apt-get install -y --no-install-recommends containerd
469
+ rm -rf /var/lib/apt/lists/*
470
+ }
471
+
439
472
function ensure-container-runtime {
440
473
container_runtime=" ${CONTAINER_RUNTIME:- docker} "
441
474
if [[ " ${container_runtime} " == " docker" ]]; then
@@ -448,11 +481,17 @@ function ensure-container-runtime {
448
481
fi
449
482
docker version
450
483
elif [[ " ${container_runtime} " == " containerd" ]]; then
484
+ set -x
451
485
if ! command -v ctr > /dev/null 2>&1 ; then
452
- echo " ERROR ctr not found. Aborting."
453
- exit 2
486
+ install-containerd
487
+ if ! command -v containerd > /dev/null 2>&1 ; then
488
+ echo " ERROR containerd not found. Aborting."
489
+ exit 2
490
+ fi
454
491
fi
455
- ctr version
492
+ ctr --version
493
+ containerd --version
494
+ runc --version
456
495
fi
457
496
}
458
497
0 commit comments