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 multi-architecture builds in the devcontainer CLI #5652

Closed
Chuxel opened this issue Sep 29, 2021 · 4 comments
Closed

Support multi-architecture builds in the devcontainer CLI #5652

Chuxel opened this issue Sep 29, 2021 · 4 comments
Assignees
Labels
cli containers Issue in vscode-remote containers plan-item A plan item
Milestone

Comments

@Chuxel
Copy link
Member

Chuxel commented Sep 29, 2021

Currently, the devcontainer build command will build for your current architecture. While this has worked well historically, the arrival of M1 macs has created a challenge particularly for CI systems (that are nearly always running x86) to generate both x86 and arm64 images.

To resolve this, we could provide an option that will buildx to build multiple architectures (or the equivalant command for other docker-esque clis we end up supporting). However, note that the buildx --load option that makes the image available for local use does not support multiple --platform values today. As a result, if a single platform is specified we can use the load option, otherwise we would not. We can also expose something analogous to --push to automatically push to image registries.

//cc @chrmarti @joshspicer

@Chuxel Chuxel added containers Issue in vscode-remote containers feature-request Request for new features or functionality cli labels Sep 29, 2021
@KrisJanssen
Copy link

Is there any update on this? Indeed hitting issues trying to use a Dev container on an M1 system... having the container build with a forced --platform linux/amd64 would solve that.

@chrmarti
Copy link
Contributor

chrmarti commented Jan 3, 2022

Setting the DOCKER_DEFAULT_PLATFORM environment variable (see https://docs.docker.com/engine/reference/commandline/cli) should work.

@Chuxel
Copy link
Member Author

Chuxel commented Jan 3, 2022

@chrmarti DOCKER_DEFAULT_PLATFORM works for single platform, but not multi-platform as far as I am aware. I believe this does a --load with the result which doesn't work with multi-arch. What we need to be able to do is accept multiple platforms and do a build + push for CI scenarios (doing a buildx --load in multi-architecture situations also does not work). Using --platform on buildx is how the vscode-dev-containers repository is set up, so I tried a bunch of different variations. See https://docs.docker.com/desktop/multi-arch/ and the build system source here.

Here's what the env var does in multi-arch scenarios:

$ export DOCKER_DEFAULT_PLATFORM="linux/arm64,linux/amd64"
$ devcontainer build .
[330 ms] Start: Run: docker build -f c:\Users\clantz\Desktop\temp\.devcontainer\Dockerfile -t vsc-temp-ba790444e0186a7a1b5080f93ae363a9 --build-arg VARIANT=bullseye c:\Users\clantz\Desktop\temp\.devcontainer
Error response from daemon: "\"linux" is an invalid component of "\"linux/arm64,linux/amd64\"": platform specifier component must match "^[A-Za-z0-9_-]+$": invalid argument

Doing two builds does not really provide a path for multiple architectures to be associated with the same image name. Otherwise, if we don't do that, you need a separate devcontianer.json for ARM vs x86_64 referencing different image names, which is also something we do not support well today. There's a hacky old manifest way of doing this (see "The hard way with docker manifest"), but the goal with this feature request is to have this as a built-in capability given how common it will be for any org with Macs in it.

@chrmarti
Copy link
Contributor

chrmarti commented Jan 4, 2022

@Chuxel Forgot to qualify my suggestion: In @KrisJanssen's case DOCKER_DEFAULT_PLATFORM might work since that appears to only require a single platform. The original feature request cannot be solved with that. Thanks for clarifying.

@chrmarti chrmarti added plan-item A plan item and removed feature-request Request for new features or functionality labels Jun 27, 2022
@chrmarti chrmarti self-assigned this Jun 27, 2022
@chrmarti chrmarti added this to the June 2022 milestone Jun 27, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cli containers Issue in vscode-remote containers plan-item A plan item
Projects
None yet
Development

No branches or pull requests

3 participants