Skip to content

docker build from a docker CLI inside a container leaves the image out of Kiri's store (buildx makes a docker-container "default" builder) #734

Done

Description

@masihmoloodian

Kiri version and system

Kiri built from source: main at f9cd271, with #731 on top. #731 doesn't touch builds. macOS 27.2.1 (Apple M4 Pro); the docker CLI inside the container is 29.9.3 with buildx v0.39.0 (docker:cli).

What you did

A docker CLI in a container, talking to Kiri through the mounted socket, as CI runners and self-hosted platforms (Dokploy, #603) do:

docker --context kiri run --rm -v /var/run/docker.sock:/var/run/docker.sock docker:cli sh -c '
  mkdir /b && cd /b && printf "FROM alpine\nRUN echo hi > /x\n" > Dockerfile
  docker build -t probe-incontainer .
  docker image inspect probe-incontainer --format "{{.Id}}"'

What happened

The build succeeds, but the image is not in Kiri's store:

#0 building with "default" instance using docker-container driver
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
Error response from daemon: No such image: probe-incontainer

What you expected instead

The image in the engine's store, as with Docker Engine 29.8.2 (OrbStack), running the same command:

#0 building with "default" instance using docker driver
#6 naming to docker.io/library/probe-incontainer:latest done
sha256:91df84d17208240a60d2037450b8a76e9f73d…

Anything else

  • Why it happens: Kiri's /_ping says Builder-Version: 1, since there's no BuildKit inside the engine (Built-in builder: Serve Docker's build endpoints (/session, /grpc) so buildx works with its docker driver #49). So buildx in the container can't use its docker driver. It makes its own builder called default, with the docker-container driver (it starts buildx_buildkit_default), and without default-load. The result stays in that builder's cache.

  • Why the Mac's own CLI works: kiri setup makes the kiri-build builder with --driver-opt default-load=true (crates/kiri/src/builds.rs). A CLI in a container has nothing like it.

  • A builder of your own doesn't help: docker build keeps using the default builder, even after docker buildx create --driver-opt default-load=true and docker buildx use --default on that builder (tried in Dokploy's container: CLI 28.5.2, buildx 0.39.0).

  • Workaround: DOCKER_BUILDKIT=0 (Kiri's classic POST /build) puts the image in the store:

    $ docker --context kiri run --rm -e DOCKER_BUILDKIT=0 -v /var/run/docker.sock:/var/run/docker.sock docker:cli sh -c '… docker build -t probe-incontainer . …'
    Successfully tagged probe-incontainer:latest
    

    That is what Dokploy needed to deploy from Git in the Swarm on one node: services, stacks, secrets and configs, so Dokploy runs #731 test. The classic builder is deprecated in the CLI, though, and buildx-only options don't work with it.

  • Fixes I can see:

    Happy to look into it if one of these is wanted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions