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
- Try to get caching to work Based on this comment, since the example I was working from wasn't working as-is: <https://github.com/docker/build-push-action/issues/163#issuecomment-918569148> — committed to myersjustinc/bumper-curve-bot by myersjustinc 3 years ago
- chore: disable docker cache https://github.com/docker/build-push-action/issues/163 — committed to cloud-cli/image-node by darlanalves 2 years ago
- fix: unintentional docker release config override After some more digging, it looks like the culprit might be azure's docker login changing setting for buildx. see: https://github.com/docker/build-p... — committed to wasmCloud/wash by vados-cosmonic 8 months ago
- fix: unintentional docker release config override After some more digging, it looks like the culprit might be azure's docker login changing setting for buildx. see: https://github.com/docker/build-p... — committed to connorsmith256/wasmCloud by vados-cosmonic 8 months ago
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-buildxazure/docker-logindocker/build-push-actionThe
azure/docker-loginaction was setting theDOCKER_CONFIGenvironment 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 fromazure/docker-logintodocker/login-action, or change the order so thatazure/docker-logincomes beforedocker/setup-docker-buildx.So if you’re using
docker/setup-docker-buildxaction with the default driver (docker-container) and yourdocker/build-push-actioncomplains about thedockerdriver 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 workflowsection quotes code without adocker/setup-buildx-actionstep. But if you run withoutsetup-buildx-actionyou will get the same error saying:Not necessarily related to
type=ghacache 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:
And the settings,
driveranddriver-opts, are not documented in the example as necessary so it is a very misleading example.I’m not. I’m talking about this: GitHub Cache Found by following Cache -> GitHub cache under Advanced usage