嘿, 我是Mofei!
3,194
Force Docker to Use amd64 on Apple M1 Chips
April 14, 2022 at 10:38 AM

Using Docker images built on Apple's M1 chip - Apple Silicon chip to deploy with AMD64 architecture mechines such as Linux or Windows (AWS EC2, ECS, Alibaba Cloud Function Compute, etc.) will bring some issues. Therefore, in order to deploy the image built by Apple chips on the above platforms, we need to specify the image to build the AMD64 architecture.

There are several ways to achieve this:

  1. Specify DOCKER_DEFAULT_PLATFORM parameter in your environment

    You can run export DOCKER_DEFAULT_PLATFORM=linux/amd64 directly before building, or put this in your env config files, e.g. .bashrc, .zshenv or .zshrc etc. by doing this will avoid setting it every time.

  2. Specify the platform in the From of the Dockerfile

    For example

    FROM --platform=linux/amd64 python:3.6
  3. If building with docker-compose, you can specify paltform: linux/amd64

    services:
       servername:
         platform: linux/amd64
         ......
    

Reference source: https://stackoverflow.com/questions/65612411/forcing-docker-to-use-linux-amd64-platform-by-default-on-macos

THE END

If there’s something worth discussing, leave a comment and let’s talk!

Mofei's Friend

avatar
What's on your mind today?
No comments yet
Be the first to comment!

HI. I AM MOFEI!

NICE TO MEET YOU!