3

So I have docker environment, and want to use the Remote Containers VScode extension to attach my editor to a container.

But I need to specify the platform while building, otherwise it doesn't work

This build command works:

docker buildx build --file Dockerfile.local --platform linux/amd64 -t webapp . --load

However, when I use "Open folder in container" option from Remote-containers, I found in the build log that it's being started with this command:

docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /Users/macbook/webapp/Dockerfile.local -t vsc-webapp-d6a884082a6b83d4c1a0444e21b1d8e0 /Users/macbook/webapp

So the build Fails.

How can I tell remote-containers to use --platform linux/amd64 while building?

I tried adding this to devcontainer.json and didn't work:

"build": { "args": { "DOCKER_DEFAULT_PLATFORM": "linux/amd64" }}

and

"containerEnv": { "DOCKER_DEFAULT_PLATFORM": "linux/amd64" }

hecontreraso
  • 1,221
  • 3
  • 15
  • 23

1 Answers1

1

The only solution I found was adding the platform information directly in Dockerfile

FROM --platform=linux/amd64 python:3.8-slim
mona-mk
  • 101
  • 2
  • 4