build-push-action: v2: docker driver doesn't support auto-push

I’m experimenting with the v2 branch and ran into an issue with the basic use case below. Notice it’s using the default builder (no setup-buildx-action step) with the docker driver.

jobs:
  build:
    - uses: actions/checkout@v2

    - uses: docker/login-action@v1
      with:
        registry: ${{ env.REGISTRY }}
        username: ${{ env.USER }}
        password: ${{ secrets.PASSWORD }}

    - uses: docker/build-push-action@v2-build-push
      with:
        context: .
        tags: ${{ env.REGISTRY }}/myapp:latest
        push: true

The output for the build step is:

Run docker/build-push-action@v2-build-push
📣 Buildx version: 0.4.2
🏃 Starting build...
/usr/bin/docker buildx build --tag myregistry.io/myapp:latest --iidfile /tmp/docker-build-push-Ghos6S/iidfile --file ./Dockerfile --push .
auto-push is currently not implemented for docker driver
##[error]The process '/usr/bin/docker' failed with exit code 1

I realize the error is coming from buildx upstream, but considering this action is called “build-push”, I think users would expect this functionality to be implemented by the action if the underlying tool doesn’t support it — or at least have a large warning in the README. My use case is more complex than this example, and part of the appeal of this action is that it seamlessly handles pushing a dynamic number of tags.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 17
  • Comments: 17 (9 by maintainers)

Commits related to this issue

Most upvoted comments

You have three possibilities atm (the first one being the more straightforward).

With docker-container driver (via setup-buildx)

jobs:
  build:
    - uses: actions/checkout@v2
    - uses: docker/setup-buildx-action@v1
    - uses: docker/login-action@v1
      with:
        registry: ${{ env.REGISTRY }}
        username: ${{ env.USER }}
        password: ${{ secrets.PASSWORD }}
    - uses: docker/build-push-action@v2
      with:
        context: .
        tags: ${{ env.REGISTRY }}/myapp:latest
        push: true

With docker driver (without setup-buildx)

jobs:
  build:
    - uses: actions/checkout@v2
    - uses: docker/login-action@v1
      with:
        registry: ${{ env.REGISTRY }}
        username: ${{ env.USER }}
        password: ${{ secrets.PASSWORD }}
    - uses: docker/build-push-action@v2
      with:
        context: .
        tags: ${{ env.REGISTRY }}/myapp:latest
        load: true
    - run: docker push ${{ env.REGISTRY }}/myapp:latest

With docker driver (with setup-buildx)

jobs:
  build:
    - uses: actions/checkout@v2
    - uses: docker/setup-buildx-action@v1
      with:
        driver: docker
    - uses: docker/login-action@v1
      with:
        registry: ${{ env.REGISTRY }}
        username: ${{ env.USER }}
        password: ${{ secrets.PASSWORD }}
    - uses: docker/build-push-action@v2
      with:
        context: .
        tags: ${{ env.REGISTRY }}/myapp:latest
        load: true
    - run: docker push ${{ env.REGISTRY }}/myapp:latest

And it should fix this current issue.

@crazy-max It doesn’t look like this issue has been fixed yet.

The result is the same with the setup-buildx step.

jobs:
  build:
    - uses: actions/checkout@v2

    - uses: docker/setup-buildx-action@v1
      with:
        driver: docker

    - uses: docker/login-action@v1
      with:
        registry: ${{ env.REGISTRY }}
        username: ${{ env.USER }}
        password: ${{ secrets.PASSWORD }}

    - uses: docker/build-push-action@v2
      with:
        context: .
        tags: ${{ env.REGISTRY }}/myapp:latest
        push: true

Again, I know this is an upstream limitation, but I believe it makes sense for docker/build-push-action to support this basic use case despite buildx’s lack of support for it.

I think it’s better to separate the build part from the setup part.

I agree. I really like the decision to extract login and setup from v2. 👍

In this case, the environment is already set up to use the docker driver. I don’t expect this action to change that setup. I do expect an action called docker/build-push-action to be able to push images built with docker.

Thanks for considering, and great work with v2 so far!

Ubuntu virtual environments have been updated and now use Buildx 0.5.1 so it should be available through docker/buildx#442.

wow, seems v1 is easy to use, I can login, build and push in single step.

I started trying to use v2 to get rid of warning, did I miss anything?

name: Publish Docker image
on:
  release:
    types: [published]
jobs:
  push_to_registry:
    name: Push Docker image to GitHub Packages
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repo
        uses: actions/checkout@v2
      - name: Push to GitHub Packages
        uses: docker/build-push-action@v1
        with:
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
          registry: docker.pkg.github.com
          repository: my-org/my-repo/my-image
          tag_with_ref: true