-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
exec: use qemu emulator automatically #1516
Conversation
Dockerfile
Outdated
@@ -101,6 +101,8 @@ RUN --mount=target=. --mount=target=/root/.cache,type=cache \ | |||
|
|||
FROM scratch AS binaries-linux-helper | |||
COPY --from=runc /usr/bin/runc /buildkit-runc | |||
# built from https://github.com/tonistiigi/binfmt/tree/85394e2a1bf0ac9e6c291945e869322bea969445 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -708,6 +708,17 @@ func (e *execOp) Exec(ctx context.Context, inputs []solver.Result) ([]solver.Res | |||
return nil, err | |||
} | |||
|
|||
emu, err := getEmulator(e.platform, e.cm.IdentityMapping()) | |||
if err == nil && emu != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log error instead of silencing it
solver/llbsolver/ops/exec_binfmt.go
Outdated
return []mount.Mount{{ | ||
Type: "bind", | ||
Source: filepath.Join(tmpdir, qemuMountName), | ||
Options: []string{"ro", "rbind"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting ro
and rbind
together isn't useful because it does not make the mountpoint recursively read-only.
Signed-off-by: Tonis Tiigi <[email protected]>
fixes #1513
This allows emulation for multi-arch in 6 most popular architectures without kernel being configured with binfmt_misc. If kernel is configured binfmt_misc is used instead.
Currently, all the qemu binaries are included with the image. After gzip for x86 this means ~7MB size increase. https://github.com/tonistiigi/binfmt/releases/tag/test0 That should be ok for most cases. I'm not sure if it is ok for Moby though so maybe we should also allow qemu to be pulled from the image during build. There may be licensing issues as well for shipping these qemu binaries with dockerd.
Another possible optimization would be to avoid cloning emulator binary for each exec. Some cache could be introduced.
The approach of switching entrypoint seems to work on my test builds but lmk if you can spot some possible issues with this.
Signed-off-by: Tonis Tiigi [email protected]