Search code examples
dockerapple-m1vscode-devcontainer

How to run Docker in devcontainers on Mac M1 Apple Silicon?


I'm on a project where I'm the only Mac user on the team and want to use Docker in a vscode devcontainer. I keep getting dependency issues because my architecture is different.

I've tried to set the remoteEnv to use the variable DOCKER_DEFAULT_PLATFORM=amd64, which didn't work. You can't detect the operating system and do conditional runArgs yet https://github.com/microsoft/vscode-remote-release/issues/3972


Solution

  • What I ended up doing is using Rosetta, which allows apple silicon to run Intel processor apps.

    I'm using colima for my docker runner. So to start Docker I run

    colima start --vz-rosetta --vm-type vz --arch x86_64
    

    It's very missable but on the Docker Install guide for Mac it shares how to install Rosetta.

    https://docs.docker.com/desktop/install/mac-install/

    softwareupdate --install-rosetta

    If all else fails just add --platform linux/amd64 as a runArgs to the devcontainer. It may not break other folks'. Otherwise I'm recommending to just run a Docker container not a devcontainer.

    Or in the head of the Dockerfile you could add FROM --platform=linux/amd64 <Docker image name>