GitHub Container Registry (GHCR)
Free private registry for GitHub users.
Authentication
bash
1# Create Personal Access Token with 'packages' scope
2# Then login
3echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdinPushing Images
bash
1# Tag for GHCR
2docker tag myapp:latest ghcr.io/username/myapp:latest
3
4# Push
5docker push ghcr.io/username/myapp:latestIn GitHub Actions
yaml
1- name: Login to GHCR
2 uses: docker/login-action@v2
3 with:
4 registry: ghcr.io
5 username: ${{ github.actor }}
6 password: ${{ secrets.GITHUB_TOKEN }}
7
8- name: Build and Push
9 uses: docker/build-push-action@v4
10 with:
11 push: true
12 tags: ghcr.io/${{ github.repository }}:latestPackage Visibility
- Private by default
- Can be linked to repository
- Access controlled via repository settings
