Specify platform when building a docker container via Docker SDK for Python

Viewed 543

I'm trying to build an Alpine-based NGINX Docker image on a Raspberry Pi 4 running Ubuntu 20.04 LTS (64 bit).

Since I also have an older Raspberry Py 3 which is running on Raspbian (32 bit), I want that image to be a 32 bit version, which is why I specify FROM arm32v7/alpine:3.13 in the Dockerfile.

I trigger the build via the SDK by calling

stream = client.api.build(path=dockerfile_dir,
                          dockerfile='Dockerfile-Lastbuild',
                          tag=config['tag'],
                          labels=config['labels'],
                          platform='linux/arm/v7', # <- Ignored?
                          rm=True)

Then I'm getting the warning

[Warning] The requested image's platform (linux/arm) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

I thought that by adding the argument platform='linux/arm/v7', as specified in the documentation:

platform (str) – Platform in the format os[/arch[/variant]].

, I would be instructing Docker that I am requesting a specific platform.

When I just specify FROM alpine:3.13 I'm getting the same warnings.

Only when I specify FROM arm64v8/alpine:3.13 the warnings disappear, but I assume that the resulting image is no longer compatible with arm32v7, which would be a requirement to run on the Raspberry Pi 3 (32 bit).

I haven't tried it manually via the console, which is something I will do next, but what exactly is the purpose of that platform argument then?


I noticed that if I remove the platform argument, and then use FROM alpine:3.13 the warnings disappear. So I assume that this argument only has effect on which variant of the Alpine image is pulled by default.

This does not explain what is meant by and no specific platform was requested.

0 Answers
Related