Skip to content

Bug | Docker MultiArch won´t run with the current set up #32

@juanmatias

Description

@juanmatias

Describe the Bug

The current docker-hub-build-push-single-arg-multi-arch.mk setup is not working, buildx needs to be configured.

Expected Behavior

When this makefile is called a Multiarch build has to be done.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Include this Makefile in your makefile, e.g.:
init-makefiles: ## initialize makefiles
	@rm -rf ${MAKEFILES_DIR}
	@mkdir -p ${MAKEFILES_DIR}
	@git clone https://github.com/binbashar/le-dev-makefiles.git ${MAKEFILES_DIR} -q
	@cd ${MAKEFILES_DIR} && git checkout ${MAKEFILES_VER} -q
-include ${MAKEFILES_DIR}/docker/docker-hub-build-push-single-arg-multi-arch.mk
  1. Call the recipe called build
  2. See error
docker buildx build \
	--platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7,linux/arm/v8 \
	-t binbash/leverage-toolbox:1.2.1-0.0.1 \
	--build-arg DOCKER_TAG='1.2.1-0.0.1' .
[+] Building 0.0s (0/0)                                                         
error: multiple platforms feature is currently not supported for docker driver. Please switch to a different driver (eg. "docker buildx create --use")
make[1]: *** [../@bin/makefiles/docker/docker-hub-build-push-single-arg-multi-arch.mk:15: build] Error 1
make[1]: Leaving directory '/home/circleci/project/leverage-cli'

Screenshots

n/a

Environment (please complete the following information):

CircleCI runners and local tested.
Local:

$ uname -a
Linux tufmanjaro 5.15.59-1-MANJARO #1 SMP PREEMPT Wed Aug 3 11:20:04 UTC 2022 x86_64 GNU/Linux

$ docker --version
Docker version 20.10.17, build 100c70180f

$ docker buildx version
github.com/docker/buildx v0.8.2-docker 6224def4dd2c3d347eee19db595348c50d7cb491

Additional Context

In this specific Makefile docker is being used with buildx to allow multi arch builds.

Solution

As per binbashar/le-docker-leverage-toolbox#7 these lines are required previous the build:

docker run --privileged --rm tonistiigi/binfmt --install all && \
docker buildx create --name container --driver docker-container

then the build line needs no platform, container indication and --load flag for local testing:

	docker buildx build \
	    --builder=container \
	    --load \
		-t ${DOCKER_REPO_NAME}/${DOCKER_IMG_NAME}:${DOCKER_TAG} \
		--build-arg DOCKER_TAG='${DOCKER_TAG}'${OTHER_DOCKER_ARGS} .

and container indication and --push flag for build+push:

	@docker buildx build \
	    --builder=container \
		--platform ${TARGET_PLATFORMS_INTERNAL} \
		--push \
		-t ${DOCKER_REPO_NAME}/${DOCKER_IMG_NAME}:${DOCKER_TAG} \
		--build-arg DOCKER_TAG='${DOCKER_TAG}'${OTHER_DOCKER_ARGS} .

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpatch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions