Using DockerHub in Akraino Edge Stack & Other Linux Foundation Projects
By Kaly Xin, Eric Ball, and Cristina Pauna
DockerHub is the world’s largest library and community for container images. It offers a huge repository for storing container images and it is available world wide. It can automatically build container images from GitHub and Bitbucket and push them to Docker Hub. These are just a few of the features it provides, but maybe one of the best features is that it offers seamless support for multi arch images through fat manifest.
Why Docker Hub is recommended for Multi-Arch
Docker Hub registry is able to store manifest list (or fat manifests). A manifest list acts as a pointer to other images built for a specific architecture thus making it possible to use the same name for images that are built on hardware with different architectures.
Figure 1: Docker registry storing amd64, arm64 images and their fat manifest
In the picture above akraino/validation:k8s-latest is the fat manifest, and its name can be used to reference both images akraino/validation:k8s-amd64-latest and akraino/validation:k8s-arm64-latest. Inspecting the manifest offers the details on what images it has, for what hardware architecture and what OS.
Figure 2: Docker fat manifest details
How does it work?
When building an image for a specific arch, the arch is added in the tag of the image (akraino/validation:k8s-amd64-latest and akraino/validation:k8s-arm64-latest).
After the images are pushed in the Docker Hub repo, the manifest can be created from the two images. Its name will be the same as the two images but with the arch removed from the tag (akraino/validation:k8s-latest).
To do this in CI with Jenkins, the Jenkins slave has to have docker and a couple of other LF tools installed. The connection to Docker Hub is done through LF scripts (see releng-global-jjb for more info) and all you need to do is define the jjb jobs .
The Akraino validation project is already pushing to Dockerhub, so if you would like to check out some template code, take a look at ci-management/jjb/validation. The docker images are pushed in the official repo and the docker build jobs are running daily.
In the figure below, the main Jenkins job (validation-master-docker) triggers two parallel jobs that build and push into the Docker Hub registry the amd64 (akraino/validation:k8s-amd64-latest ) and arm64 (akraino/validation:k8s-arm64-latest ) images. At the end, the fat manifest (akraino/validation:k8s-latest ) is done in a separate job.
When pulling the image, the name of the manifest is used (akraino/validation:k8s-latest); the correct image will be pulled based on the architecture of the host from which the pull is made.
Figure 4: Pulling a docker image from two different hardware architecture servers using the same name
Docker Hub has been integrated in LF projects like OPNFV from the beginning and is now integrated in Akraino too, so other open source projects can refer to this successful experience to integrate Docker Hub in their pipeline.