Docker builds are broken if buildkit is used (DOCKER_BUILDKIT=1)

After the upgrade https://changelog.travis-ci.com/xenial-build-environment-updates-95336
all docker builds stopped working at once, as we have to use buildkit to passthrough the ssh-agent.

How to reproduce:

  1. Create the Dockerfile
# syntax=docker/dockerfile:1.0.0-experimental
FROM node:8-alpine
  1. Try to build it with DOCKER_BUILDKIT=1 docker build -t test .
  2. Get a very subtle error
#3 resolve image config for docker.io/docker/dockerfile@sha256:d2d402b6fa1d...
#3       digest: sha256:225ddc2c45be66b63dfcfb873b0d39a2fe4d12bf16cbd5a14f411b724fb674c8
#3         name: "resolve image config for docker.io/docker/dockerfile@sha256:d2d402b6fa1dae752f8c688d72066a912d7042cc1727213f7990cdb57f60df0c"
#3      started: 2019-04-11 23:13:58.29101229 +0000 UTC
#3    completed: 2019-04-11 23:13:58.581553479 +0000 UTC
#3     duration: 290.541189ms
#3        error: "docker.io/docker/dockerfile@sha256:d2d402b6fa1dae752f8c688d72066a912d7042cc1727213f7990cdb57f60df0c not found"
docker.io/docker/dockerfile@sha256:d2d402b6fa1dae752f8c688d72066a912d7042cc1727213f7990cdb57f60df0c not found

Solution: Removing the gcr.io from mirrors helps. Just do echo "{}" > /etc/docker/daemon.json.

Here is the relevant issue: https://github.com/moby/buildkit/issues/606#issuecomment-453959632

@ekini I also ran into this problem, and edit /etc/docker/daemon.json is forbidden by travisCI, do you have any workaround now?

@youyongsong I don’t think it’s forbidden. Just use sudo and it should work.

I have tried sudo, it’s still forbidden to edit or cat. I’m now using buildkit daemon + buildctl in travis:

before_install:
  - sudo docker run -d --privileged -p 1234:1234 --name buildkit moby/buildkit:latest --addr tcp://0.0.0.0:1234
  - sudo docker cp buildkit:/usr/bin/buildctl /usr/bin/
  - export BUILDKIT_HOST=tcp://0.0.0.0:1234

jobs:
  include:
  - stage: "test and build"
    script:
    - buildctl build --frontend dockerfile.v0 --local context=. --local dockerfile=. --opt target=ci