Force Docker to use AMD64 in Apple Silicon ( Apple M1 ) chips
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:
DOCKER_DEFAULT_PLATFORMparameter in your environment
You can run
export DOCKER_DEFAULT_PLATFORM=linux/amd64directly before building, or put this in your env config files, e.g.
.zshrcetc. by doing this will avoid setting it every time.
Specify the platform in the From of the
FROM --platform=linux/amd64 python:3.6
If building with
docker-compose, you can specify
services: servername: platform: linux/amd64 ......
Reference source: https://stackoverflow.com/questions/65612411/forcing-docker-to-use-linux-amd64-platform-by-default-on-macos