Skip to content

exec: use qemu emulator automatically#1516

Merged
AkihiroSuda merged 1 commit intomoby:masterfrom
tonistiigi:qemu-emulator
Jun 9, 2020
Merged

exec: use qemu emulator automatically#1516
AkihiroSuda merged 1 commit intomoby:masterfrom
tonistiigi:qemu-emulator

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 tonistiigi@gmail.com

Dockerfile Outdated

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.

}

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.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
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