Disclaimer: I am new to Docker and am aware of my ignorance.
I am trying to build a Docker container with the amd64 architecture on computer with Apple's M1 Pro. I have specified platform: linux/amd64
in the docker-compose.yml
as well as FROM --platform=linux/amd64
in the Dockerfile (both simultaneously and individually).
If I include it in the Dockerfile for that container, it builds fine but uname -a
in that shell shows aarch64
architecture (not x86_64
).
If I include it in docker-compose.yml
, I get the following error:
Error response from daemon: image with reference api:latest was found but does not match the specified platform: wanted linux/amd64, actual: linux/arm64/v8
where api
is one of the containers I am trying to build with docker-compose
.
File Structure:
.
├── api
│ ├── Dockerfile-API
│ ├── entrypoint.sh
│ └── ...
├── db
│ └── ...
├── docker-compose.yml
└── nginx
└── ...
./docker-compose.yml
:
version: '3.0'
services:
db:
...
api:
platform: linux/amd64 # line in question
build:
context: ./api
dockerfile: Dockerfile-API
command: ./run.sh
depends_on:
- db
env_file: local.env
networks:
- nginx_network
expose:
- "8000"
ports:
- "3000:3000"
image: api:latest
...
nginx:
...
networks:
nginx_network:
external: true
volumes:
...
./api/Dockerfile-API
FROM --platform=linux/amd64 python3.6 # line in question
...
From directory .
with platform set in docker-compose.yml
:
$ docker-compose down
$ docker-compose up
Error response from daemon: image with reference api:latest was found but does not match the specified platform: wanted linux/amd64, actual: linux/arm64/v8
From directory .
with platform set in ./api/Dockerfile-API
:
$ docker-compose down
$ docker-compose up -d
$ docker-compose exec api bash
> uname -a
Linux bc17e565c265 5.10.104-linuxkit #1 SMP PREEMPT Thu Mar 17 17:05:54 UTC 2022 aarch64 GNU/Linux
I am grateful for any ideas/suggestions about why this is happening and how to fix it. Rosetta 2 is installed on my machine and Docker is up-to-date. Thank you!