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 --platform docker CLI argument to target the image architecture to be produced. #97

Closed
Oneiroi opened this issue Apr 13, 2022 · 3 comments · Fixed by #103
Closed

Comments

@Oneiroi
Copy link

Oneiroi commented Apr 13, 2022

Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

Support for docker's --platform option added to docker pull, to support cross arch image builds from differing architecture host OS's

Use Case(s)

packer use aarch64 operating systems such as M1 and other M Series Apple silicon, future Thinkpad X13s snapdragon use

Potential configuration

Amendment of this section

cmd := exec.Command("docker", "pull", image)
to permit the passing of the platform/arch target (injecting --platform e.g. docker pull --platform=linux/amd64 image:TAG (https://docs.docker.com/engine/reference/commandline/pull/#options)

Potential References

https://docs.docker.com/engine/reference/commandline/pull/#options

hcl file snippet:

...
source "docker" "oraclelinux" {
  image  = "--platform=linux/amd64 oraclelinux:8"
  commit = true
}
...

packer build -debug:

==> oraclelinux.docker.oraclelinux: Pausing after run of step 'StepTempDir'. Press enter to continue. 
==> oraclelinux.docker.oraclelinux: Pulling Docker image: --platform=linux/amd64 oraclelinux:8
    oraclelinux.docker.oraclelinux: "docker pull" requires exactly 1 argument.
    oraclelinux.docker.oraclelinux: See 'docker pull --help'.
    oraclelinux.docker.oraclelinux: Usage:  docker pull [OPTIONS] NAME[:TAG|@DIGEST]
    oraclelinux.docker.oraclelinux: Pull an image or a repository from a registry

Image string does not appear to be passed verbatim, as the following shows this is valid:

docker pull --platform=linux/amd64 oraclelinux:8
8: Pulling from library/oraclelinux
Digest: sha256:a0b7d2abffd01d284bd0db50c7f45abec5f8585e8a4cbf14a172a7a0362c2759
Status: Image is up to date for oraclelinux:8
docker.io/library/oraclelinux:8
@lifeofguenter
Copy link
Contributor

lifeofguenter commented Jun 21, 2022

This should be also added to the post-processors.

@pySilver
Copy link

Is there any workaround until #103 is merged?

devashish-patel pushed a commit that referenced this issue Jul 13, 2022
@devashish-patel
Copy link
Contributor

We have released v1.0.6 with this enhancement. CHANGELOG

Example template:

source "docker" "oraclelinux" {
  image    = "oraclelinux:8"
  platform = "linux/amd64"
  commit   = true
}

build {
  name = "docker-with-platform"
  sources = [
    "source.docker.oraclelinux",
  ]
}

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