we are trying to use a private docker image hosted on the Github Package of our organization. Something like this:
on: push
jobs:
runner-job:
runs-on: ubuntu-latest
services:
postgres:
# Github Registry image here
image: ghcr.io/orgname/reponame:tag
But we are getting an unauthorized error, which is normal, becuase the registry is private. Is there some way to login? I have not found any way or docs.
CodePudding user response:
You have to add credentials to each service where you use an image from a private repository. From the docs:
If the image's container registry requires authentication to pull the image, you can use
credentials
to set amap
of theusername
andpassword
. The credentials are the same values that you would provide to the docker login command.
And here is an example:
on: push
jobs:
runner-job:
runs-on: ubuntu-latest
services:
postgres:
image: ghcr.io/orgname/reponame:tag
# add this to each service with an image from a private repo
credentials:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
This example implies that you have two secrets: DOCKER_USER
and DOCKER_PASSWORD
.