-
Notifications
You must be signed in to change notification settings - Fork 455
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
Multi architecture deployment using different Dockerfiles? #805
Comments
You can use |
I don't know your specific situation, but with BuildKit, you're also able to make stages conditional, based on build-args. The built-in For example, the following Dockerfile has both # syntax=docker/dockerfile:1
FROM alpine AS base
# arm64-specific stage
FROM base AS build-arm64
RUN echo "This stage is used on arm64"
# amd64-specific stage
FROM base AS build-amd64
RUN echo "This stage is used on amd64 (x86)"
# common steps
FROM build-${TARGETARCH} AS build
RUN echo "This stage is used on all architectures" Building the above with docker build --no-cache --platform=linux/amd64 --progress=plain .
...
#9 [build-amd64 1/1] RUN echo "This stage is used on amd64 (x86)"
...
#10 [build 1/1] RUN echo "This stage is used on all architectures"
...
#10 DONE 0.4s And building teh above with docker build --no-cache --platform=linux/arm64 --progress=plain .
...
#9 [build-arm64 1/1] RUN echo "This stage is used on arm64"
...
#10 [build 1/1] RUN echo "This stage is used on all architectures"
...
#10 DONE 0.3s |
Thanks for the reply @tonistiigi. I was aware of the option, but not quite sure how to use it. If I don't use a tag I get:
If I use the same command, but add a tag in the
and confirm by doing:
If I add the
Any idea on what I am doing wrong? I wasn't able to find too much information on examples on using This is my buildx setup if it helps:
|
@thaJeztah thank you for that. Excellent explanation on how to use the stages. I used that method for some of our repos, but we have a couple of cases where I couldn't work around separate Dockerfiles. |
Your name needs to be only the repo name. Without the |
@tonistiigi thank you! |
Hello,
I am wondering if there is a "clean" method of pushing multi-arch images to DockerHub, without using a separate tag.
Essentially I am trying to achieve the magic that
docker buildx build --platform linux/amd64,linux/arm64 --tag <user>/<repo>:<tag> . --push
provides, (i.e. one tag with multi-arch images), but using a multi-step build process since I need to use a different Dockerfile per architecture.To circle back to my first sentence, the only way I have been able to achieve this is as follows:
docker buildx build --platform linux/amd64 -f Dockerfile1--tag <user>/<repo>:<tag> . --push
docker buildx build --platform linux/arm64 -f Dockerfile2 --tag <user>/<repo>:<tag>_arm64 . --push
docker buildx imagetools create --append -t <user>/<repo>:<tag> <user>/<repo>:<tag>_arm64
When I go to my Docker Hub and look in this repo, under I see the digests of the 2 arch builds, which is what I want. Of course I also see a separate tag,
<tag>_arm64
which comes from the build in the second step, and as I understand it, this is necessary because you can't append an image from the local repo to a remote repo, so I have to push it to DockerHub before using imagetools.Is there a better way of doing this that doesn't require the creation and pushing of the second tag?
The text was updated successfully, but these errors were encountered: