Col*_*air 13 docker docker-compose apple-m1
免责声明:我是 Docker 新手,知道自己的无知。
\n我正在尝试使用 Apple M1 Pro 在计算机上构建具有 amd64 架构的 Docker 容器。我已platform: linux/amd64
在Dockerfiledocker-compose.yml
和FROM --platform=linux/amd64
Dockerfile 中指定(同时和单独)。
如果我将它包含在该容器的 Dockerfile 中,它构建得很好,但uname -a
在该 shell 中显示aarch64
架构(不是x86_64
)。
如果我将其包含在 中docker-compose.yml
,则会出现以下错误:
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\n
Run Code Online (Sandbox Code Playgroud)\napi
我正在尝试构建的容器之一在哪里docker-compose
。
文件结构:
\n.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 api\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Dockerfile-API\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 entrypoint.sh\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 ...\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 db\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 ...\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 docker-compose.yml\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 nginx\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 ...\n
Run Code Online (Sandbox Code Playgroud)\n./docker-compose.yml
:
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\n
Run Code Online (Sandbox Code Playgroud)\n./api/Dockerfile-API
FROM --platform=linux/amd64 python3.6 # line in question\n...\n
Run Code Online (Sandbox Code Playgroud)\n.
从平台设置的目录docker-compose.yml
:
.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 api\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Dockerfile-API\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 entrypoint.sh\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 ...\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 db\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 ...\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 docker-compose.yml\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 nginx\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 ...\n
Run Code Online (Sandbox Code Playgroud)\n.
从平台设置的目录./api/Dockerfile-API
:
version: \'3.0\'\nservices:\n db:\n ...\n api:\n platform: linux/amd64 # line in question\n build:\n context: ./api\n dockerfile: Dockerfile-API\n command: ./run.sh\n depends_on:\n - db\n env_file: local.env\n networks:\n - nginx_network\n expose:\n - "8000"\n ports:\n - "3000:3000"\n image: api:latest\n ...\n nginx:\n ...\n\nnetworks:\n nginx_network:\n external: true\n\nvolumes:\n ...\n
Run Code Online (Sandbox Code Playgroud)\n我很感激任何关于为什么会发生这种情况以及如何解决它的想法/建议。我的机器上安装了 Rosetta 2,并且 Docker 是最新的。谢谢你!
\nCol*_*air 10
事实证明,这docker-compose down
并不等同于删除图像。通过 Docker Desktop GUI删除api
映像然后重新构建 ( docker-compose up
) 后,我能够创建具有x86_64
架构的容器。
归档时间: |
|
查看次数: |
18962 次 |
最近记录: |