Docker Community Forums

Share and learn in the Docker community.

Pull different images on same OS/Arch

Hi,

I wonder if there is a possiblity to add two images with the same OS/Arch to one manifest and pull the “right” one automatically based on other labels than OS & Arch.

In my case I have two Nvidia Jetson devices, differing in their Jetpack Version, which leads to two images having the Linux/Arm64 under the same manifest.

I hope for a possibility to label the Host devices (Jetson boards)/Images, such that Docker knows to pull the correct one pending on the Jetpack version.

This label task hasn’t to done automatically by Docker for my usage.

Thanks in advance

Before the addition of manifests and multiarch docker hub images, a trivial way to specify an architecture was something like ppc64le/ubuntu:xenial. Now the architecture is chosen automatically (based on golang runtime.GOARCH), but there absolutely is no way to change or specify it.

Linux kernel binfmt_misc feature, together with e.g. QEMU (or some other emulator), provide a way to run a container image using a different architecture. For example, on any recent Debian or Ubuntu x86_64, as root:

mkdir xxx && cd xxx
apt install qemu-user-static

this step might be optional

test -f /proc/sys/fs/binfmt_misc/aarch64 || echo ‘:aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-aarch64-static:’ > /proc/sys/fs/binfmt_misc/register
cp /usr/bin/qemu-aarch64-static .
cat << EOF > Dockerfile
FROM arm64v8/ubuntu:bionic
COPY qemu-aarch64-static /usr/bin/qemu-aarch64-static
EOF
docker build -t ubuntu-qemu .
Once the image is built, you can test it:

uname -a
Linux kd 4.14.23+ #46 SMP Fri Mar 2 10:31:35 PST 2018 x86_64 x86_64 x86_64 GNU/Linux

docker run ubuntu-qemu uname -a
Linux b0a309929288 4.14.23+ #46 SMP Fri Mar 2 10:31:35 PST 2018 aarch64 aarch64 aarch64 GNU/Linux
Now, if I am to use multiarch support, there is no way to tell docker the image architecture. i.e. both docker build with a Dockerfile containing FROM ubuntu and docker pull ubuntu will always pull image of the architecture under which the docker binary was built (i.e. runtime.GOARCH).

The other problem is resulting image architecture (also assumed to be runtime.GOARCH) is wrong:

docker image inspect ubuntu-qemu | grep Arch
“Architecture”: “amd64”,

Hi, thanks for the input. Though building is not a problem and the OS/Arch should be for both Jetson Boards linux/aarch64.

I have found out that manifest annotate has --os-features option, but there is no documentation and google search hasn’t yielded much either.

I hope that this labeling mechanism allows me to achieve what I want: putting a label on my boards, such that the image with the correct label gets pulled.

But I can’t find how these OS Features are defined…