Skip to main content

Connecting a repository to a package

You can connect a repository to a container image on your GitHub Enterprise Server instance.

By connecting a repository to a package, the package landing page will show information and links from the repository, such as the README.

Connecting a repository to a user-owned package on GitHub

  1. On GitHub, navigate to the main page of your personal account.

  2. In the top right corner of GitHub Enterprise Server, click your profile photo, then click Your profile. Profile photo

  3. On your profile page, in the top right, click Packages. Packages option on profile page

  4. Under your package versions, click Connect repository. Connect a repository button on packages landing page

  5. Select a repository, then click Connect repository. Connect a repository button in repository selection pop-up window

Connecting a repository to an organization-owned package on GitHub

  1. On GitHub, navigate to the main page of your organization.

  2. Under your organization name, click Packages.

    Packages tab on org landing page

  1. Under your package versions, click Connect repository. Connect a repository button on packages landing page

  2. Select a repository, then click Connect repository. Connect a repository button in repository selection pop-up window

Connecting a repository to a container image using the command line

Note: Container registry is currently in beta for GitHub Enterprise Server and subject to change.

Both GitHub Packages and subdomain isolation must be enabled to use Container registry. For more information, see "Working with the Container registry."

  1. In your Dockerfile, add this line, replacing HOSTNAME, OWNER and REPO with your details:

    LABEL org.opencontainers.image.source=https://HOSTNAME/OWNER/REPO

    For example, if you're the user monalisa and own my-repo, and your GitHub Enterprise Server instance hostname is github.companyname.com, you would add this line to your Dockerfile:

    LABEL org.opencontainers.image.source=https://containers.github.companyname.com/monalisa/my-repo

    For more information, see "LABEL" in the official Docker documentation and "Pre-defined Annotation Keys" in the opencontainers/image-spec repository.

  2. Build your container image. This example builds an image from the Dockerfile in the current directory and assigns the image name hello_docker.

    $ docker build -t hello_docker .
  3. Optionally, review details for the Docker image you want to tag.

    $ docker images
    > REPOSITORY                                                    TAG                 IMAGE ID            CREATED             SIZE
    > containers.github.companyname.com/my-org/hello_docker         latest              38f737a91f39        47 hours ago        91.7MB
    > containers.github.companyname.com/my-username/hello_docker    latest              38f737a91f39        47 hours ago        91.7MB
    > hello-world                                                   latest              fce289e99eb9        16 months ago       1.84kB
  4. Tag your Docker image with your desired image name and hosting destination.

    $ docker tag IMAGE_NAME containers.HOSTNAME/OWNER/NEW_IMAGE_NAME:TAG

    For example:

    $ docker tag 38f737a91f39 containers.github.companyname.com/monalisa/hello_docker:latest
  5. If you haven't already, authenticate to the Container registry. For more information, see "Authenticating to the Container registry."

    $ echo $CR_PAT | docker login containers.HOSTNAME -u USERNAME --password-stdin
    > Login Succeeded
  6. Push your container image to the Container registry.

    $ docker push containers.HOSTNAME/OWNER/IMAGE-NAME:TAG

    For example:

    $ docker push containers.github.companyname.com/monalisa/hello_docker:latest