Skip to content

Unclear error when try build with docker-buildx-qemu

Hi, I have tried to use your image with gitlab-runner but I got a strange error:

failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /tmp/buildkit-mount006396345/Dockerfile: no such file or directory

How I run gitab-runner:

docker run -d --name gitlab-runner --restart always   -v /home/sr/gitlab-runner/config:/etc/gitlab-runner   -v /var/run/docker.sock:/var/run/docker.sock  --privileged  gitlab/gitlab-runner:alpine

/home/sr/gitlab-runner/config.toml:

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "NAME"
  url = "URL"
  token = "TOKEN"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.docker]
    tls_verify = false
    image = "docker:dind"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

.gitlab CI:

variables:
  DOCKER_TLS_CERTDIR: ""
  DOCKER_HOST: tcp://docker:2375/
  BUILDKIT_INLINE_CACHE: '1'
  DOCKER_DRIVER: overlay2
  CI_BUILD_ARCHS: "linux/amd64"
  CI_BUILD_IMAGE: "ixdotai/docker-buildx-qemu:latest"

build:test:
  image: $CI_BUILD_IMAGE
  stage: build
  services:
    - docker:dind
  retry: 2
  before_script:
    - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
    - update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel
    # Use docker-container driver to allow useful features (push/multi-platform)
    - docker context create MyContext
    - docker buildx create --driver docker-container --name MyContext --use MyContext
    - docker buildx inspect --bootstrap
  script:
    - docker buildx ls
    - docker buildx build --platform $CI_BUILD_ARCHS --progress plain --pull -t "$CI_REGISTRY_IMAGE" .
  after_script:
    - docker build rm
  tags: [docker-dind, qemu]

And the result from pipeline:

Pulling docker image ixdotai/docker-buildx-qemu:latest ...
Using docker image sha256:8b266bbc8e3d59412fb6ea530bde9e701b7fa671861c2c472966be756000ae09 for ixdotai/docker-buildx-qemu:latest with digest ixdotai/docker-buildx-qemu@sha256:6b552f2bb7001acaa303d2978ad0267017b0ee230eeb89ee370755a1607388cd ...
Preparing environment
00:01
Running on runner-yvcbxzxr-project-344-concurrent-0 via 1edc95163af3...
Getting source from Git repository
00:02
Fetching changes...
Reinitialized existing Git repository in /builds/botldr/service-tools/.git/
Checking out ea937dce as test-botldr-update...
Skipping Git submodules setup
Executing "step_script" stage of the job script
$ echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
$ update-binfmts --enable
$ docker context create MyContext
MyContext
Successfully created context "MyContext"
$ docker buildx create --driver docker-container --name MyContext --use MyContext
MyContext
$ docker buildx inspect --bootstrap
#1 [internal] booting buildkit
#1 pulling image moby/buildkit:buildx-stable-1
#1 pulling image moby/buildkit:buildx-stable-1 16.9s done
#1 creating container buildx_buildkit_mycontext0
#1 creating container buildx_buildkit_mycontext0 2.7s done
#1 DONE 19.6s
Name:   MyContext
Driver: docker-container
Nodes:
Name:      mycontext0
Endpoint:  MyContext
Status:    running
Platforms: linux/amd64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6, linux/riscv64, linux/arm64
$ docker buildx ls
NAME/NODE    DRIVER/ENDPOINT  STATUS  PLATFORMS
MyContext *  docker-container         
  mycontext0 MyContext        running linux/amd64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6, linux/riscv64, linux/arm64
MyContext    docker                   
  MyContext  MyContext        running linux/amd64, linux/riscv64, linux/386, linux/arm/v7, linux/arm/v6
default      docker                   
  default    default          running linux/amd64, linux/riscv64, linux/386, linux/arm/v7, linux/arm/v6
$ docker buildx build --platform $CI_BUILD_ARCHS --progress plain --pull -t "$CI_REGISTRY_IMAGE" .
time="2020-09-23T11:18:34Z" level=warning msg="invalid non-bool value for BUILDX_NO_DEFAULT_LOAD: "
time="2020-09-23T11:18:34Z" level=warning msg="No output specified for 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"
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 2B done
#1 DONE 0.1s
#2 [internal] load .dockerignore
#2 transferring context: 2B done
#2 DONE 0.1s
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /tmp/buildkit-mount006396345/Dockerfile: no such file or directory
Running after_script
Running after script...
$ docker build rm
unable to prepare context: path "rm" not found
ERROR: Job failed: exit code 1