How to use images from GitHub Packages on a GitLab Pipeline?

328 Views Asked by At

I'm trying to pull an image that a simple

docker pull ghcr.io/geosales-evolution/fastlane-linux-flutter-android-dockerimage:0.0.2

would be enough. But my GitLab pipeline gives an error:

Running with gitlab-runner 16.3.0~beta.108.g2b6048b4 (2b6048b4)
  on green-5.saas-linux-small-amd64.runners-manager.gitlab.com/default xS6Vzpvo, system ID: s_6b1e4f06fcfd
  feature flags: FF_USE_IMPROVED_URL_MASKING:true, FF_RESOLVE_FULL_TLS_CHAIN:false
Preparing the "docker+machine" executor
00:04
Using Docker executor with image ghcr.io/geosales-evolution/fastlane-linux-flutter-android-dockerimage:0.0.2 ...
Pulling docker image ghcr.io/geosales-evolution/fastlane-linux-flutter-android-dockerimage:0.0.2 ...
WARNING: Failed to pull image with policy "always": Error response from daemon: Get https://ghcr.io/v2/geosales-evolution/fastlane-linux-flutter-android-dockerimage/manifests/0.0.2: unauthorized (manager.go:237:0s)
ERROR: Job failed: failed to pull image "ghcr.io/geosales-evolution/fastlane-linux-flutter-android-dockerimage:0.0.2" with specified policies [always]: Error response from daemon: Get https://ghcr.io/v2/geosales-evolution/fastlane-linux-flutter-android-dockerimage/manifests/0.0.2: unauthorized (manager.go:237:0s)

I wrote a pipeline using the desired image and it should have executed the job and echoed "Hello, World!"

My .gitlab-ci.yml

stages:
  - build

custom_image_job:
  stage: build
  image:
    name: ghcr.io/geosales-evolution/fastlane-linux-flutter-android-dockerimage:0.0.2
  script:
    - echo "Hello, World!"
1

There are 1 best solutions below

1
quizguy On

If you are using a self hosted runner - on the machine it’s on you need to authenticate to the container registry using something like docker login and then your GitHub credentials. You can probably use a pat token for this to make it a little easier.

If you are using gitlab as a service I’m not sure what you could use - maybe running the image download like docker-in-docker style or something. Hope this helps.