<p>Im trying to run a cron job in a digital ocean kubernetes cluster. The image is hosted as a github package. I am getting an authenticatin error when the image is being pulled. I also get the same error when trying to pull directly from docker in the command line. Is that the same problem? Or do I need to auth in 2 differnet places?</p>
<p>docker publish github
source: <a href="https://github.com/actions/starter-workflows/blob/aa9d3bc6cc46ac11a53ca196e504d4f901a8de8d/ci/docker-publish.yml" rel="nofollow noreferrer">https://github.com/actions/starter-workflows/blob/aa9d3bc6cc46ac11a53ca196e504d4f901a8de8d/ci/docker-publish.yml</a></p>
<pre><code>name: Docker

on:
  push:
    # Publish `master` as Docker `latest` image.
    branches:
      - master

    # Publish `v1.2.3` tags as releases.
    tags:
      - v*

  # Run tests for any PRs.
  pull_request:

env:
  # TODO: Change variable to your image's name.
  IMAGE_NAME: image

jobs:
  # Run tests.
  # See also https://docs.docker.com/docker-hub/builds/automated-testing/
  test:
    ru    fi

  # Push image to GitHub Packages.
  # See also https://docs.docker.com/docker-hub/builds/
  push:
    # Ensure test job passes before pushing image.
    needs: test

    runs-on: ubuntu-latest
    if: github.event_name == 'push'

    steps:
      - uses: actions/checkout@v2

      - name: Build image
        run: docker build . --file Dockerfile --tag $IMAGE_NAME

      - name: Log into registry
        run: echo &quot;${{ secrets.GITHUB_TOKEN }}&quot; | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin

      - name: Push image
        run: |
          IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME

          # Change all uppercase to lowercase
          IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')

          # Strip git ref prefix from version
          VERSION=$(echo &quot;${{ github.ref }}&quot; | sed -e 's,.*/\(.*\),\1,')

          # Strip &quot;v&quot; prefix from tag name
          [[ &quot;${{ github.ref }}&quot; == &quot;refs/tags/&quot;* ]] &amp;&amp; VERSION=$(echo $VERSION | sed -e 's/^v//')

          # Use Docker `latest` tag convention
          [ &quot;$VERSION&quot; == &quot;master&quot; ] &amp;&amp; VERSION=latest

          echo IMAGE_ID=$IMAGE_ID
          echo VERSION=$VERSION

          docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
          docker push $IMAGE_ID:$VERSION
      docker build . --file Dockerfile
          fi

  # Push image to GitHub Packages.
  # See also https://docs.docker.com/docker-hub/builds/
  push:
    # Ensure test job passes before pushing image.
    needs: test

    runs-on: ubuntu-latest
    if: github.event_name == 'push'

    steps:
      - uses: actions/checkout@v2

      - name: Build image
        run: docker build . --file Dockerfile --tag $IMAGE_NAME

      - name: Log into registry
        run: echo &quot;${{ secrets.GITHUB_TOKEN }}&quot; | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin

      - name: Push image
        run: |
          IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME

          # Change all uppercase to lowercase
          IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')

          # Strip git ref prefix from version
          VERSION=$(echo &quot;${{ github.ref }}&quot; | sed -e 's,.*/\(.*\),\1,')

          # Strip &quot;v&quot; prefix from tag name
          [[ &quot;${{ github.ref }}&quot; == &quot;refs/tags/&quot;* ]] &amp;&amp; VERSION=$(echo $VERSION | sed -e 's/^v//')

          # Use Docker `latest` tag convention
          [ &quot;$VERSION&quot; == &quot;master&quot; ] &amp;&amp; VERSION=latest

          echo IMAGE_ID=$IMAGE_ID
          echo VERSION=$VERSION

          docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
          docker push $IMAGE_ID:$VERSION
</code></pre>
<p>cron service</p>
<pre><code> apiVersion: batch/v1beta1
    kind: CronJob
    metadata:
      name: test1
    spec:
      schedule: &quot;*/15 * * * *&quot;
      jobTemplate:
        spec:
          template:
            spec:
              containers:
                - name: data
                  image: docker.pkg.github.com/lambda-capital/k8s-test/image:latest
              restartPolicy: OnFailure
</code></pre>

tlalco
<p>You can't pull anonymously from <code>docker.pkg.github.com</code>, you'll have to create a dockercfg with some GitHub access token and use it as <code>imagePullSecret</code>.</p>
<p>If you want to publicly host your image on GitHub you can use the newer <code>ghcr.io</code> container registry, which provides anonymous pulling capabilities for public images.</p>
