Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging in to two Docker registries? #59

Closed
roderik opened this issue Jun 11, 2020 · 3 comments
Closed

Logging in to two Docker registries? #59

roderik opened this issue Jun 11, 2020 · 3 comments
Milestone

Comments

@roderik
Copy link

roderik commented Jun 11, 2020

I'm trying to build a docker container, from a private container on dockerhub, and push it to the github registry.

For public dockerhub packages, this works splendidly

  docker-rabbitmq:
    runs-on: ubuntu-latest
    needs: lerna
    steps:
      - name: Checkout repo
        uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}
      - name: Build the container
        uses: docker/build-push-action@v1
        with:
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
          registry: docker.pkg.github.com
          repository: xxx/yyy/rabbitmq
          tag_with_ref: true
          dockerfile: ./packages/yyy/containers/rabbitmq/Dockerfile
          cache_froms: xxx/yyy/rabbitmq:latest
          path: ./packages/yyy/containers/rabbitmq/

But for a private container, this fails because we are not logged in to DockerHub.

I tried to add the following before the build-push-action, but that does not get picked up

      - uses: azure/docker-login@v1
        with:
          username: "xxx"
          password: "xxx"

Any ideas on how to do this?

@roderik
Copy link
Author

roderik commented Jun 11, 2020

FYI, if your containers do not have the same name, this is a workaround

  docker-zzz:
    runs-on: ubuntu-latest
    needs: lerna
    steps:
      - name: Checkout repo
        uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}

      - uses: azure/docker-login@v1
        with:
          username: "xxx"
          password: "xxx"

      - run: |
          docker pull xxx/yyy:3.9.1

      - name: Build the container
        uses: docker/build-push-action@v1
        with:
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
          registry: docker.pkg.github.com
          repository: xxx/yyy/zzz
          tag_with_ref: true
          dockerfile: ./packages/yyy/containers/zzz/Dockerfile
          cache_froms: xxx/yyy/zzz:latest
          path: ./packages/yyy/containers/zzz/

@crazy-max
Copy link
Member

crazy-max commented Sep 2, 2020

This will be available through build-push-action v2 (#92) and more precisely the login-action. Can you try it?

@crazy-max crazy-max added this to the v2 milestone Sep 2, 2020
@crazy-max
Copy link
Member

Version 2 has been merged to the main branch and is therefore available via uses: docker/build-push-action@v2 (mutable tag).

As a reminder, this new version changes drastically and works with 3 new actions (login, setup-buildx and setup-qemu) that we have created. Many usage examples have been added to handle most use cases.

And it should fix this current issue. Don't hesitate if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants