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?
docker buildx use <builder> will switch to the specified builder instance. The buildx instance performs build tasks in two ways, the two execution methods are referred to as using different drivers. docker driver: executes a build using the BuildKit library integrated in the Docker service application.
In your docker file use base image with support for arm. E.g. ubuntu docker build --platform arm --pull -t your_tag . This command will force docker to pull arm version of the base image and will also set arm architecture to your result image.
The build element define configuration options that are applied by Compose implementations to build Docker image from source. build can be specified either as a string containing a path to the build context or a detailed structure:
Try the docker buildx bake command. Official documentation says: Use the -f / --file option to specify the build definition file to use. The file can be a Docker Compose, JSON or HCL file. It also lets you pass the names of the targets to build, to build only specific targets.
You can use buildx in docker-compose by setting ENV variable COMPOSE_DOCKER_CLI_BUILD=1
, also if buildx is not set as default, you should add DOCKER_BUILDKIT=1
:
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With