balena-io-library / resin-rpi-raspbian

Apache License 2.0
74 stars 27 forks source link

Images on Docker Hub have incorrect architecture (amd64) #104

Closed thaJeztah closed 3 years ago

thaJeztah commented 3 years ago

I noticed that the images on docker hub have the incorrect architecture set, which causes problems when attempting to run the image with the --platform option on docker run and docker pull.

For example; https://hub.docker.com/layers/balenalib/rpi-raspbian/buster/images/sha256-be127ba5ed82eb62cba0dc833d81bbce035de3d599d7f65de2f9bf1863f04b43?context=explore

Screenshot 2021-01-29 at 13 01 07

Using the download-frozen-image-v2.sh script to pull the raw data from Docker Hub (to verify an architecture was set, or if it was "blank");

$ mkdir balena-buster
$ ./contrib/download-frozen-image-v2.sh ./balena-buster balenalib/rpi-raspbian:buster@sha256:be127ba5ed82eb62cba0dc833d81bbce035de3d599d7f65de2f9bf1863f04b43

$ cat ./balena-buster/51b1ef245ec93c1345d53463e43b5ed29d0922a073b5e8a98d41980eb9a3f0e8.json | jq .architecture
"amd64"
thaJeztah commented 3 years ago

More details about this in https://github.com/docker/for-linux/issues/1170#issuecomment-750478242 (and related: https://github.com/moby/moby/pull/41873)

This causes a problem on Docker 20.10 if a user explicitly requests a --platform;

When pulling the image, there's (currently) no problem, because the image is not a multi-architecture image, in which case docker pull in itself does not do platform/architecture selection;

$ docker pull balenalib/rpi-raspbian:buster
buster: Pulling from balenalib/rpi-raspbian
Digest: sha256:be127ba5ed82eb62cba0dc833d81bbce035de3d599d7f65de2f9bf1863f04b43
Status: Image is up to date for balenalib/rpi-raspbian:buster
docker.io/balenalib/rpi-raspbian:buster

$ docker pull --platform linux/armhf balenalib/rpi-raspbian:buster
buster: Pulling from balenalib/rpi-raspbian
Digest: sha256:be127ba5ed82eb62cba0dc833d81bbce035de3d599d7f65de2f9bf1863f04b43
Status: Image is up to date for balenalib/rpi-raspbian:buster
docker.io/balenalib/rpi-raspbian:buster

Running the pulled image also works if no --platform is specified, in which case docker runs the image that's present in the local image cache irregardless it's os/architecture (The image may still fail to run if the host does not support running the given os/arch);

$ docker run -it --rm balenalib/rpi-raspbian:buster uname -a
Linux 05ea43f50f96 4.19.121-linuxkit #1 SMP Tue Dec 1 17:50:32 UTC 2020 armv6l GNU/Linux

However, when explicitly requesting a specific architecture, docker will perform a lookup in the local image cache; if the requested architecture is not available, it will attempt to pull (again), after which it checks the image architecture and fail if it doesn't match;

$ docker run -it --rm --platform linux/armhf balenalib/rpi-raspbian:buster uname -a
Unable to find image 'balenalib/rpi-raspbian:buster' locally
buster: Pulling from balenalib/rpi-raspbian
Digest: sha256:be127ba5ed82eb62cba0dc833d81bbce035de3d599d7f65de2f9bf1863f04b43
Status: Image is up to date for balenalib/rpi-raspbian:buster
docker: Error response from daemon: image with reference balenalib/rpi-raspbian:buster was found but does not match the specified platform: wanted linux/arm, actual: linux/armhf.
See 'docker run --help'.
nghiant2710 commented 3 years ago

hey @thaJeztah, thank you for the report. We acknowledged the issue but these image are currently built on some build servers with old Docker installed (v17) so can't correctly set the platform/architecture for them yet.

We're working on migrating all our Docker base image builds to the new build servers and will be able to fix the platform/architecture issue as soon as the migration is completed.

Again sorry for the inconvenience and we will keep you updated here.

thaJeztah commented 3 years ago

Thanks! I see the :latest image is now linux/arm 👍 https://hub.docker.com/r/balenalib/rpi-raspbian/tags?page=1&ordering=last_updated

Screenshot 2021-04-06 at 17 37 07

Is it expected that the existing (:buster, :bullseye) images are not yet rebuilt/updated?

nghiant2710 commented 3 years ago

@thaJeztah, other tags will be available very soon, I will keep you informed.

thaJeztah commented 3 years ago

Great, thanks!

nghiant2710 commented 3 years ago

@thaJeztah, just want to let you know that all rpi-raspbian base images with correct architecture are available. Thank you for your patience and please let me know if you find any issues.

This issue will be closed now.