Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to specify --platform argument image pull option for multi platform images #1532

Closed
vivanov83 opened this issue Mar 1, 2022 · 16 comments

Comments

@vivanov83
Copy link

It's supported when doing build but I think while pulling images we're not passing this. We can fix this issue alongside this issue.

Originally posted by @rohanKanojia in #1516 (comment)

Does this part is fixed, or planed to be fixed?
If it's fixed already, may I have an example how we're defining multiplatform image pull in xml

@rohanKanojia
Copy link
Member

rohanKanojia commented Mar 1, 2022

While doing build docker maven plugin would ignore this platform parameter. You'd need to provide platform in XML configuration :

      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>docker-maven-plugin</artifactId>
	<version>0.39.1</version>
	<configuration>
            <images>
                <image>
                     <!- .. ->
                     <build>
                          <createImageOptions>
                              <platform>linux/amd64</platform>
                          </createImageOptions>
                     </build>
                </image>
            </images>
        </configuration>
      </plugin>

@vivanov83
Copy link
Author

Yeah, I saw that, but this option is only for building/creating images, not for pulling them in FROM section defined in Dockerfile as an example :
FROM --platform=linux/arm64 debian:stretch-slim
If my build platform is x86 based or x64 not ARM for example, the final image will be x based, and the only workaround I can see here is to define parent image to be the platform I / you want.Am I right ?

@rohanKanojia
Copy link
Member

This option should work for pulling images. When you're pulling, you're creating image as well on your docker host.I think you'd need to set platform to the platform you're current docker host is based (from where you're pulling it).

@rhuss
Copy link
Collaborator

rhuss commented Mar 14, 2022

@rohanKanojia @vivanov83 could you please fix the subject of this issue ?

@rohanKanojia rohanKanojia changed the title It's supported when doing build but I think while pulling images we're not passing this. We can fix this issue alongside this issue. How to specify --platform argument image pull option for multi platform images Mar 14, 2022
@rohanKanojia
Copy link
Member

@vivanov83 : polite ping, Did you get time to try my suggestion?

@vivanov83
Copy link
Author

vivanov83 commented Mar 14, 2022

Let me explain differently :
In order to build for example ARM image what you need :
1 - st ARM based parent image (a.k.a FROM )
2 - nd provide parameters for docker to build arm based image(a.k.a docker build ... --platform ARM)
If you don't specify --platform when you're doing FROM operation then docker daemon will pull the image based on the host architecture.
I one word/sentence . I would like to build ARM based images on x86-64 hosts, but if there is no way to pulling the proper parent image then this is not gonna work.
Correct me if I'm wrong

@chonton
Copy link
Contributor

chonton commented May 6, 2022

Consider trying buildx support just added in #1548

@rohanKanojia
Copy link
Member

buildx support should be available in 0.40.0 . Please try it out and provide us feedback!

@chonton
Copy link
Contributor

chonton commented Jul 9, 2022

@rohanKanojia please close

@AhHa45
Copy link

AhHa45 commented Dec 14, 2022

buildx support should be available in 0.40.0 . Please try it out and provide us feedback!

I don't understand how this is related to the image pull...the buildx.platforms setting does not help.
(Doesn't even make sense since we're not building anything we just want to pull the right image)
I am on a apple macbook pro m1 (with an arm64 cpu) and get this warning:

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

how to pull the right image?!

<execution>
    <id>start-postgres</id>
    <phase>pre-integration-test</phase>
    <goals>
        <goal>start</goal>
    </goals>
    <configuration>
        <images>
            <image>
                <name>postgres:12.7</name>
                <alias>postgres</alias>
                <build>
                    <buildx>
                        <platforms>linux/arm64</platforms>
                    </buildx>
                </build>
                <run>
                    ...
                </run>
            </image>
        </images>
    </configuration>
</execution>

@chonton
Copy link
Contributor

chonton commented Dec 16, 2022

Docker will just pull the right image if you don't specify

@AhHa45
Copy link

AhHa45 commented Dec 16, 2022

Docker will just pull the right image if you don't specify

as you can see in the warning I posted, it does not.

@chonton
Copy link
Contributor

chonton commented Dec 16, 2022

SInce you have specified

                    <buildx>
                        <platforms>linux/arm64</platforms>
                    </buildx>

only the linux/arm64 platform will be pulled. Since your macbook needs a linux/arm64/v8 image, this warning appears.

If you remove the platforms section above, docker should be smart enough to pull the appropriate image.

@AhHa45
Copy link

AhHa45 commented Dec 23, 2022

confirmed, thx @chonton

@sta-szek
Copy link

hi, i faced the same issue, however the buildx did not help me for RUN CONFIGURATION

in my case, there is a single sentence in docs that pointed me to fix:

platform | Specify an explicit platform to use when starting a docker container. May be set with property docker.platform. Defaults to native platform.

in given section: http://dmp.fabric8.io/#start-configuration

i think it could be a bit better documented, that those two options are different - one for build and the other for run. also, the docs contain exampel for build, but not for run.

also, as stated in docs:

May be set with property docker.platform.

setting <docker.plaform> in maven properties, or -Ddocker.platform when running maven command does not work at all.

the only working option for me is to override parent plugin image configuration and specify like this:

<plugins>
    <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <configuration>
            <autoPull>always</autoPull>
            <images>
                <image>
                    <name>registry.dev.coresuite.com/postgresql-ms-test:latest</name>
                    <alias>postgres</alias>
                    <run>
                        <platform> linux/amd64</platform>
...

@liry
Copy link

liry commented Feb 8, 2024

FYI: I've created an issue to either make it work for runnig or fix the docs: #1750

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants