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

Support for Docker option: --platform #1157

Closed
jesperdj opened this issue Dec 1, 2021 · 3 comments · Fixed by #1241
Closed

Support for Docker option: --platform #1157

jesperdj opened this issue Dec 1, 2021 · 3 comments · Fixed by #1241
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@jesperdj
Copy link

jesperdj commented Dec 1, 2021

Description

Info

  • Eclipse JKube version : 1.5.1
  • Maven version (mvn -v) : 3.8.4
  • Kubernetes / Red Hat OpenShift setup and version : N/A (Not using Kubernetes, I just want to build Docker images)
  • If it's a bug, how to reproduce : Not a bug
  • If it's a feature request, what is your use case :

I am using a new MacBook Pro with Apple Silicon (M1 Max CPU, arm64 architecture).

I have to use some Docker base images for which there is unfortunately no native arm64 version available. This is no problem in principle; it's possible to run Docker containers for the amd64 architecture (= Intel x86_64) on this machine through Rosetta 2. (Note: Don't confuse the architecture names: arm64 = Apple Silicon, amd64 = Intel x86_64).

However: When I pull or build an image, Docker will by default try to pull or build an image for the native architecture (arm64). If no such image is available, it fails with an error message. It is possible to force Docker to use an image for the amd64 architecture by using the "--platform" option, for example: docker pull --platform linux/amd64 tagname

It seems that kubernetes-maven-plugin does not support supplying this option to Docker.

I tried using buildOptions as described in the documentation here: https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin#jkube:build by adding this to the plugin configuration:

<images>
    <image>
        <name>myorg/mytag</name>
        <build>
            <buildOptions>
                <platform>linux/amd64</platform>
            </buildOptions>
        </build>
        <!-- ... -->
    </image>
</images>

When I run Maven with --debug, I can see that the plugin parses this configuration correctly, but it seems it does not supply it to Docker because Docker still tries to pull the base image using the wrong architecture (arm64 instead of amd64).

I also added <apiVersion>1.41</apiVersion> to the plugin configuration. Note that platform is a supported query parameter in the Docker API v1.41.

But it still seems that kubernetes-maven-plugin does not pass this parameter to Docker.

Please make the plugin support this option, so that I can use it to build amd64 Docker images on my Apple Silicon MacBook Pro.

@rohanKanojia
Copy link
Member

You're right. We seem to be parsing build options during build REST call. But pulling image is done before actual build, and we're not processing any build option there. I think we should pass BuildOption there and pass platform query parameter
https://github.com/eclipse/jkube/blob/cce1b0de09a3657ec9000b3097d7266daa49aaec/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/access/hc/DockerAccessWithHcClient.java#L416-L420

@chenzhiguo
Copy link

Is this problem solved?

@manusa
Copy link
Member

manusa commented Jan 26, 2022

Not yet, I'll try to implement a quick fix to see if we can make it to 1.6 release.

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

Successfully merging a pull request may close this issue.

4 participants