@@ -407,7 +407,7 @@ function load-docker-images {
407
407
function install-docker {
408
408
# bailout if we are not on ubuntu
409
409
if ! command -v apt-get > /dev/null 2>&1 ; then
410
- echo " Unable to install automatically install docker. Bailing out..."
410
+ echo " Unable to automatically install docker. Bailing out..."
411
411
return
412
412
fi
413
413
# Install Docker deps, some of these are already installed in the image but
@@ -437,12 +437,18 @@ function install-docker {
437
437
}
438
438
439
439
# If we are on ubuntu we can try to install containerd
440
- function install-containerd {
440
+ function install-containerd-ubuntu {
441
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
442
+ if [[ -z " $( command -v lsb_release ) " || $( lsb_release -si ) != " Ubuntu " ]] ; then
443
+ echo " Unable to automatically install containerd in non-ubuntu image . Bailing out..."
444
+ exit 2
445
445
fi
446
+
447
+ if [[ $( dpkg --print-architecture) != " amd64" ]]; then
448
+ echo " Unable to automatically install containerd in non-amd64 image. Bailing out..."
449
+ exit 2
450
+ fi
451
+
446
452
# Install dependencies, some of these are already installed in the image but
447
453
# that's fine since they won't re-install and we can reuse the code below
448
454
# for another image someday.
@@ -467,6 +473,16 @@ function install-containerd {
467
473
apt-get update && \
468
474
apt-get install -y --no-install-recommends containerd
469
475
rm -rf /var/lib/apt/lists/*
476
+
477
+ # Override to latest versions of containerd and runc
478
+ systemctl stop containerd
479
+ if [[ ! -z " ${UBUNTU_INSTALL_CONTAINERD_VERSION:- } " ]]; then
480
+ curl -fsSL " https://github.com/containerd/containerd/releases/download/${UBUNTU_INSTALL_CONTAINERD_VERSION} /containerd-${UBUNTU_INSTALL_CONTAINERD_VERSION: 1} .linux-amd64.tar.gz" | tar --overwrite -xzv -C /usr/
481
+ fi
482
+ if [[ ! -z " ${UBUNTU_INSTALL_RUNC_VERSION:- } " ]]; then
483
+ curl -fsSL " https://github.com/opencontainers/runc/releases/download/${UBUNTU_INSTALL_RUNC_VERSION} /runc.amd64" --output /usr/sbin/runc && chmod 755 /usr/sbin/runc
484
+ fi
485
+ sudo systemctl start containerd
470
486
}
471
487
472
488
function ensure-container-runtime {
@@ -481,16 +497,27 @@ function ensure-container-runtime {
481
497
fi
482
498
docker version
483
499
elif [[ " ${container_runtime} " == " containerd" ]]; then
484
- set -x
500
+ # Install containerd/runc if requested
501
+ if [[ ! -z " ${UBUNTU_INSTALL_CONTAINERD_VERSION:- } " || ! -z " ${UBUNTU_INSTALL_RUNC_VERSION} " ]]; then
502
+ install-containerd-ubuntu
503
+ fi
504
+ # Verify presence and print versions of ctr, containerd, runc
485
505
if ! command -v ctr > /dev/null 2>&1 ; then
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
506
+ echo " ERROR ctr not found. Aborting."
507
+ exit 2
491
508
fi
492
509
ctr --version
510
+
511
+ if ! command -v containerd > /dev/null 2>&1 ; then
512
+ echo " ERROR containerd not found. Aborting."
513
+ exit 2
514
+ fi
493
515
containerd --version
516
+
517
+ if ! command -v runc > /dev/null 2>&1 ; then
518
+ echo " ERROR runc not found. Aborting."
519
+ exit 2
520
+ fi
494
521
runc --version
495
522
fi
496
523
}
0 commit comments