Use docker image in private github repo as base image for dockerfile

Hi I have a docker image published in one of my organization’s private repositories and I would like to use that image as the base in another project. I’ve tried a few things but I ultimately get an unauthorized or invalid reference format error. I’m trying to understand and get an example of how to accomplish this.

I’ve done repo clones using a PAT in the past like this:
git clone https://${GITHUB_PAT}@github.com/theAccount/theproject.git

I’m hoping there is some syntax I’m missing that allows me to do something like this in a dockerfile:

FROM https://${GITHUB_PAT}@ghcr.io/theAccount/theProject:latest
...
RUN otherDockerFileStuff
...

Is this possible? Is this documented and I’m missing it?
Thanks for any help :pray:

Don’t put the PAT into the URL, it’s a security issue. The recommended way to avoid having to copy it all the time is to use Git - Credential Storage, I personally recommend the cache method plus a password manager to keep the token long-term. If you really want to store the token in plain text in the repository (with all the associated security risks :warning:) you can use http.https://github.com/.extraheader to add the Authorization header with your token, that way it at least won’t show up wherever the URL does.

Remove everything before and including the @. You’ll need to docker login ghcr.io before pulling the base image instead. Use a PAT with the read:packages scope as the password.