4

I'm trying to run my npm build inside the docker container using our private docker image with GitHub actions.

My Workflow yaml file as follows,

jobs:
  build:
    runs-on: Linux-self-hosted  # This is our self hosted linux runner system.
    container:
      image: ubuntu-20.04-lts:latest  # This is our private docker image.

    steps:
    - name: Checkout Repository
      uses: actions/checkout@v2
      
    - name: Npm Build
      run: npm install

    - name: Build Package
      run: vsce package

GitHub Action Error:-

Starting job container /usr/bin/docker pull ubuntu-20.04-lts:latest Error response from daemon: pull access denied for ubuntu-20.04-lts, repository does not exist or may require 'docker login': denied: requested access to the resource is denied Warning: Docker pull failed with exit code 1, back off 4.74 seconds before retry.
/usr/bin/docker pull ubuntu-20.04-lts:latest Error response from daemon: pull access denied for ubuntu-20.04-lts, repository does not exist or may require 'docker login': denied: requested access to the resource is denied Warning: Docker pull failed with exit code 1, back off 9.535 seconds before retry. /usr/bin/docker pull ubuntu-20.04-lts:latest Error response from daemon: pull access denied for ubuntu-20.04-lts, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
Error: Docker pull failed with exit code 1

i have this ubuntu-20.04-lts:latest private docker image on my host system locally. Still it fails with above error during action build.

It looks trying to connect docker hub. How do i fix this to use our local private image?

user4948798
  • 1,924
  • 4
  • 43
  • 89
  • Not sure if you can use a local private image there. Do you also have that image in a registry? If so, try prefixing the image with the registry's name (you can also provide username/password as described here: https://github.blog/changelog/2020-09-24-github-actions-private-registry-support-for-job-and-service-containers/) – rethab Dec 13 '21 at 13:36
  • Currently the image is present in host system. Yet to be pushed to our private registry. Sure I will push the image in to our private registry and try. – user4948798 Dec 13 '21 at 13:39
  • @rethab, Thanks a lot. Image needs to pushed to private registry and post that, In the `yaml` following needs to be added. `credentials:` `username: mona` `password: ${{ secrets.docker_hub_password}}` example helped. – user4948798 Dec 14 '21 at 03:15
  • Nice :) I have added it as an answer so we can mark this question as resolved :) – rethab Dec 14 '21 at 07:32

1 Answers1

3

You'll have to push your image to your private registry. Once it is there, you can configure the credentials for your private registry as described in the docs:

container:
  image: ghcr.io/owner/image
  credentials:
     username: ${{ github.actor }}
     password: ${{ secrets.ghcr_token }}
rethab
  • 7,170
  • 29
  • 46