build-push-action: Examples don't work as expected

Troubleshooting

Before sumbitting a bug report please read the Troubleshooting doc.

Behaviour

I am trying to use buildx with cache in place of the default docker build. I am attempting to follow the general directions in the README.md of this project.

First, I am trying to just convert to using buildx in place of build. For this, I’ve tried using --load to get the images into docker. I am building images off of each other, meaning container-2 uses FROM container-1 in the Dockerfile. When using this approach, buildx doesn’t find container-1, even after building it and loading it into docker. Normal docker build works just fine.

Next, I am trying to use a local registry to cache things. I am attempting to follow the instructions found here: https://github.com/docker/build-push-action#local-registry

Steps to reproduce this issue

Please see repository linked below. I have reduced these issues to a very simple sample repository with parallel workflows demonstrating each attempt.

https://github.com/antmerlino/ghaction-docker-buildx

Expected behaviour

For buildx with --load, the expected behavior is that it builds just like regular docker build.

For buildx with local registry, the expected behavior is that I can communicate with the local registry.

Actual behaviour

For buildx with --load, the actual behavior is that buildx can’t find the first container, when building the second.

For buildx with local registry, the actual behavior is that I get a TCP error. (I think this has to do with the fact that buildx is running using the docker-container driver and something isn’t right getting back to where the docker daemon is running.) Not sure what I’m doing wrong here.

Configuration

Please see the repo linked below for a full working (or not working) example of the issues https://github.com/antmerlino/ghaction-docker-buildx

Logs

Github action on the above repo contains all logs. If something more specific is needed to help, please let me know.

Other remarks

I think if we can get this repository working with the various workflows, demonstrating what is outlined in the README.md this repository could serve as a good reference for other users who’d like to have a working reference.

Thanks for the help!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 18 (7 by maintainers)

Commits related to this issue

Most upvoted comments

It looks like I found the edge case that was causing my jobs to fail. I had the steps in this order:

  • docker/setup-docker-buildx
  • azure/docker-login
  • docker/build-push-action

The azure/docker-login action was setting the DOCKER_CONFIG environment variable for later steps so buildx setup was modifying the default configuration file (~/.docker), then the later steps all used a different configuration file. Two solutions worked here: either change from azure/docker-login to docker/login-action, or change the order so that azure/docker-login comes before docker/setup-docker-buildx.

So if you’re using docker/setup-docker-buildx action with the default driver (docker-container) and your docker/build-push-action complains about the docker driver you might have a configuration file issue.

Also noted a similar documentation issue (at lease misleading) from this page https://docs.docker.com/ci-cd/github-actions/.

The ## Optimizing the workflow section quotes code without a docker/setup-buildx-action step. But if you run without setup-buildx-action you will get the same error saying:

cache export feature is currently not supported for docker driver. Please switch to a different driver

Not necessarily related to type=gha cache but hope it help people who search the error and land here.

@crazy-max as somebody pointed out, the example is not working. I have basically copy-pasted your example for how to cache with GitHub local cache and it is giving me the same error as above. Why do you have this example, and reference it, when people say it is not working?

The real version that seems to work involves setting these values in the BuildX setup:

   ...
   - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v1
      with:
        driver: docker-container
        driver-opts: |
          image=moby/buildkit:master
          network=host
   ...

And the settings, driver and driver-opts, are not documented in the example as necessary so it is a very misleading example.

@simpers

Did you just miss what I said? Your example that you kept linking to is not up to date or accurate and that is the issue. The fact that you said “just check the example!” and then it doesn’t work just makes people waste time. Why don’t you update the example?

If you talk about this example, it works fine.

I’m not. I’m talking about this: GitHub Cache Found by following Cache -> GitHub cache under Advanced usage