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

exec: use qemu emulator automatically #1516

Merged
merged 1 commit into from
Jun 9, 2020

Conversation

tonistiigi
Copy link
Member

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]

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
Copy link
Collaborator

@tiborvass tiborvass Jun 3, 2020

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 {
Copy link
Collaborator

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

return []mount.Mount{{
Type: "bind",
Source: filepath.Join(tmpdir, qemuMountName),
Options: []string{"ro", "rbind"},
Copy link
Member

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.

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

Successfully merging this pull request may close these issues.

Automatic qemu emulation support
3 participants