The GitHub Package Registry is available for beta testing and allows us to store container images in it, basically giving us the same functionality as the Docker Hub.
However the Docker Hub only allows for one private repository per free account whereas the Github package registry is completely private! Let’s run through a simple demo to create a registry and upload an image.
First thing to do is create a personal access token in GitHub. Go to Settings > Developer Settings > Personal Access Tokens
Ensure that the token has the rights set above and click Generate Token
Now we can use that token to login to the package registry: –
TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX docker login docker.pkg.github.com -u dbafromthecold -p $TOKEN
Search for a test image. I’m going to use the busybox image which is 2MB: –
docker search busybox
Then pull the image down: –
docker pull busybox:latest
Tag the image with the repo name to be push to. The format is docker.pkg.github.com/USERNAME/REPOSITORY/IMAGE:TAG
docker tag busybox:latest docker.pkg.github.com/dbafromthecold/testrepository/busybox:latest
N.B. – the repo used has to already exist within your github account
Now push the image to the GitHub Package repository: –
docker push docker.pkg.github.com/dbafromthecold/testrepository/busybox:latest
And then you should be able to see the package in GitHub: –
Thanks for reading!