Compose does not push (--push) images during build when using docker-container driver

Hello everyone, and thank so very much for your time.

I am currently designing a continuous integration flow on Gitlab CI, where I need to be able to cache images between pipeline jobs.

As there are several images to be built, I chose to orchestrate it using docker-compose because it allows to parameterize (build-args) and cache (cache_to / cache_from) without problems.

In order to use the cache_to / cache_from statements you need to create a new builder with the docker-container driver. ( No problem with this )

When building the image and re-using the cache there are no problems, but when also trying to push the image to our registry with the --push flag, it has no effect. Only the image is built, and the cache is exported.

Here I leave examples of the step by step and the versions of the components that I am using:

$ docker info
Client:
 Version:    26.0.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.13.1
    Path:     /usr/local/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.26.0
    Path:     /usr/local/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 26.0.0
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: false
  userxattr: true
 Logging Driver: json-file
 Cgroup Driver: none
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7c3aca7a610df76212171d200ca3811ff6096eb8
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  rootless
 Kernel Version: 6.2.15-703.inttf.fc37.x86_64
 Operating System: Alpine Linux v3.19 (containerized)
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 31.25GiB
 Name: a2af2f15ac02
 ID: cab08f2b-9f79-4bf9-99fa-cc9174035a03
 Docker Root Dir: /home/ci/.local/share/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

WARNING: Running in rootless-mode without cgroups. To enable cgroups in rootless-mode, you need to boot the system in cgroup v2 mode.

A example of the docker-compose that I’m using:

services:
    builder.example:
        image: "${ORG_REGISTRY}/${BASE_NAME}/example"
        build:
            context: ../
            dockerfile: builders/example.dockerfile
            cache_from:
                - type=local,src=${DOCKER_CACHE_PATH:-/tmp/.docker}/builder.example
            cache_to:
                - type=local,dest=${DOCKER_CACHE_PATH:-/tmp/.docker}/builder.example
            tags:
                - "${PMY_REGISTRY}/${BASE_NAME}/example:${EXAMPLE_TAG:-latest}"
                - "${PMY_REGISTRY}/${BASE_NAME}/example:${EXAMPLE_TAG_MINOR:-latest}"
                - "${PMY_REGISTRY}/${BASE_NAME}/example:${EXAMPLE_TAG_MAYOR:-latest}"
            args:
                # Builder Name (Service Name without the prefix "builder." and in lowercase)
                BUILDER_NAME: "example"
                # Builder Architecture (linux/amd64, linux/arm64, linux/arm/v7, linux/arm/v6)
                BUILDER_PLATFORM: "linux/amd64"
                # Builder Image Name (ubi8/ubi-minimal, centos/centos, debian, etc.)
                BUILDER_BASE_IMAGE_NAME: "ubi8/ubi-minimal"
                # Builder Image Tag (8.4, 8.5, 8.6, etc.)
                BUILDER_BASE_IMAGE_TAG: "8.9"
                # Builder Package Manager (dnf, yum, apt, etc.)
                BUILDER_PACKAGE_MANAGER: microdnf

Note: The Dockerfile can be replaced by any.

And here is the creation of the builder I am using

2de3015da838:/app/builders# docker buildx create --use --bootstrap --name builder
[+] Building 4.3s (1/1) FINISHED
 => [internal] booting buildkit                                                                                                                                                                                                           4.3s
 => => pulling image moby/buildkit:buildx-stable-1                                                                                                                                                                                        3.5s
 => => creating container buildx_buildkit_builder0                                                                                                                                                                                        0.9s
builder
2de3015da838:/app/builders# docker buildx ls
NAME/NODE      DRIVER/ENDPOINT                          STATUS    BUILDKIT   PLATFORMS
builder*       docker-container
 \_ builder0    \_ unix:///run/user/10000/docker.sock   running   v0.13.1    linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/arm64, linux/riscv64, linux/ppc64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6
default        docker
 \_ default     \_ default                              running   v0.13.1    linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/arm64, linux/riscv64, linux/ppc64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6

Any other information you need I am at your disposal.
Again, thank you so much for your time.

UPDATE 1 (2024/03/28): Apparently it is a known bug on buildkit ~> [BUG] `build --push` does not push when building for a single platform using a docker-container builder instance · Issue #11072 · docker/compose · GitHub