I can build my dockerfile separately using following command:
docker buildx build --platform linux/arm64 -t testbuild .
now I want to use buildx in docker-compose file, but how, and how to say I want to use the arm64 architecture? This is the structure when I use the normal build.
testbuild:
build: …/testbuild
image: testbuild
Does anybody know?
您可以通过设置 ENV 变量COMPOSE_DOCKER_CLI_BUILD=1
在 docker-compose 中使用 buildx ,如果 buildx 未设置为默认值,则应添加DOCKER_BUILDKIT=1
:
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose build
In docker-compose v2.4 was add attribute platform
. Official documentation here .
Example:
version: '2.4'
services:
testbuild:
build: .../testbuild
image: testbuild
platform: linux/arm64/v8
PS Idk why, but it work only in docker-compose version 2.4
PSS About dockerx
in docker-compose, he's not there. I think because dockerx
is experimental feature in docker engine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.