Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify platform for Docker image in Visual Studio Code DevContainers

I'm using a MacBook Pro with the M2 processor (arm64) but I need to start a devcontainer with an amd64 version of the Python image (buster):

Docker image: mcr.microsoft.com/devcontainers/python:0-3.11-buster

This is what I've tried so far:

Add platform in the Dockerfile

FROM --platform=linux/amd64 mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}

Setting the DOCKER_DEFAULT_PLATFORM environment variable in .zshrc

DOCKER_DEFAULT_PLATFORM=linux/amd64

Set runArgs in devcontainer.json

  "runArgs": [
    "--platform=linux/amd64"
  ],

But for all of them I receive the following error when building the container:

[183642 ms] Start: Run: docker inspect --type image mcr.microsoft.com/vscode/devcontainers/python:3.11-buster
[185190 ms] Error fetching image details: No manifest found for mcr.microsoft.com/vscode/devcontainers/python:3.11-buster.
[185190 ms] Start: Run: docker pull mcr.microsoft.com/vscode/devcontainers/python:3.11-buster
3.11-buster: Pulling from vscode/devcontainers/python
no matching manifest for linux/arm64/v8 in the manifest list entries
[186436 ms] []
[186436 ms] Error response from daemon: No such image: mcr.microsoft.com/vscode/devcontainers/python:3.11-buster

How can I fix the platform to linux/amd64?

like image 638
Joaquín L. Robles Avatar asked May 21 '26 00:05

Joaquín L. Robles


1 Answers

In my case, I could not use runArgs in the devcontainer.json because we are using dockerComposeFile.

The solution was to configure the per-service platform inside the relevant docker-compose.yml, e.g.:

version: "3"
services:
  some-service-only-as-amd64:
    platform: linux/amd64
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 5000:5000
    volumes:

# ... and so on

like image 191
Charl Botha Avatar answered May 23 '26 20:05

Charl Botha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!