Skip to main content Link Search Menu Expand Document (external link)

2.1.3 Deploy a Public Image to GitHub Container Registry

This tutorial will demonstrate how to (1) activate GitHub Container Registry from your local device, (2) push an image to GHCR and (3) make that image public.

Pre-Requisites

Registrations

Installations

Note: Run the following commands in Terminal/Command line to verify Installations

docker -v
git -v

Activate GitHub Container Registry

  1. Navigate to GitHub Personal Access Token Creation Form
  2. Set Note to GitHubContainerRegistry
  3. Set Expiration to No expiration
  4. Select the following Scopes

     write:packages
    
     delete:packages
    
  5. Scroll Down and click Generate Token
  6. Copy your Access Token
  7. Open Terminal
  8. Follow Mac Instructions or Windows Instructions to add GHCR Token to Environment variables

Add GHCR Token to Mac Environment Variables

  1. Run the following commands
    1. Add Token to Temporary Environment Variables

       export CR_PAT=<your-token>
      
    2. Token as an Environment Variables permanently

      Mac Instructions

      Note: Depends on the type of shell you are running bash (.bash_profile) or zsh (.zshrc)

      zsh bash
      echo "\nexport CR_PAT=$CR_PAT" >> ~/.zshrc echo "\nexport CR_PAT=$CR_PAT" >> ~/.bash_profile
    3. Quit and Reopen Terminal

    4. Make sure this has been added to your Environment

       echo $CR_PAT
      
    5. Apply Token

       echo $CR_PAT | docker login ghcr.io -u <your-username> --password-stdin
      

      Note: Remove alligator clips < & >

Add GHCR Token to Windows Environment Variables

  1. Open Control Plane
  2. Click System & Security, System, Advanced System Settings, Environment Variables
  3. Under ‘System Variables’ Click New
  4. Set Variable Name to CR_PAT
  5. For Variable value paste the PAT from GitHub
  6. Press OK
  7. Restart Command Prompt
  8. Run the following command to make sure this has been added to your Environment
    set CR_PAT
    
  9. Apply Token
    echo %CR_PAT% | docker login ghcr.io -u <your-username> --password-stdin
    

    Note: Remove alligator clips < & >

Push Image to GitHub Container Registry

  1. Run the following commands
    1. Tag your Image locally
       docker tag resume-image:latest ghcr.io/<github-username>/resume-image:latest
      

      Note: Remove alligator clips < & >

    2. Test that your image was tagged sucessfully
       docker image ls
      

      Note: You should see a new image with the name ghcr.io/<github-username>/resume-image:latest

    3. Push your image to GitHub Container Registry
       docker push ghcr.io/<github-username>/resume-image:latest
      

      Note: Remove alligator clips < & >

    4. Run the following command to test that your image successfully pushed
       docker inspect ghcr.io/<github-username>/resume-image
      

      Note: Remove alligator clips < & >

Make your Image Public

  1. Navigate to your GitHub Packages from your Github Profile
  2. Select your image
  3. On the right side click Package Settings
  4. Scroll down to Danger Zone
  5. Next to Change package visibility, Click Change Visibility
  6. Select Public
  7. Complete steps for confirmation
  8. Go back to your Packages
  9. Make sure the label Private is not on your image