Creating a Repository
Find out how to create a repository in Container Registry.
After you create a repository, you can push an image to it using the Docker CLI (see Pushing Images Using the Docker CLI). Any images that you subsequently push to the registry that include the same repository name are grouped into that repository.
Creating a repository before pushing an image is the usual workflow, but it's not always necessary. If you're not authorized to manage repositories in the tenancy's root compartment, you must always push an image to an existing repository. However, if you are authorized to push images to the tenancy's root compartment and you intend to do so, an existing repository is not necessary.
When you push an image, you normally use a command in the format
docker push <region-key>.ocir.io/
<version>. However, if you select the Create repository on first push in root compartment option and push an image with a command that includes the name of a repository that doesn't already exist, a new private repository is created automatically in the root compartment.
For example, if you enter the command
docker push iad.ocir.io/ansh81vru1zp/project02/acme-web-app:7.5.2 and the
project02/acme-web-app repository doesn't exist, a private repository called
project02/acme-web-app is created automatically in the root compartment.
You must belong to the tenancy's Administrators group or have been granted the REPOSITORY_MANAGE permission on the tenancy to automatically create the private repository in the tenancy's root compartment. See Policies to Control Repository Access.
To create a repository in Container Registry using the Console, and optionally allow automatic repository creation:
- Open the navigation menu and click Developer Services. Under Containers & Artifacts, click Container Registry.
- Select the region in which to create the repository.
- Select a compartment that you have permission to work in.
- Click Create repository.
In the Create repository panel, specify details for the repository:
- Create in compartment: The compartment in which to create the repository. The default compartment is the one that you selected previously, but you can select any compartment that you have permission to work in.
- Access: Whether the repository is a public repository or a private repository. You can only make the repository public if you belong to the tenancy's Administrators group or have been granted the REPOSITORY_MANAGE permission. Note these points:
- If you make the repository public, any user with internet access and knowledge of the appropriate URL can pull images from the repository.
- If you make the repository private, you (along with users belonging to the tenancy's Administrators group) can perform any operation on the repository.
- Repository name: A name of your choice for the repository. The name you enter must be unique across all compartments in the tenancy. Avoid entering confidential information.
- Tags: Optionally, one or more free-form tags or defined tags to apply to the repository. To apply a defined tag, you must have permissions to use the tag namespace. If you are not sure whether to apply tags, skip this option (you can apply tags later) or ask your administrator. For more information, see Applying Free-form Tags and Defined Tags to Repositories, Images, and Image Signatures.
- Click Create.
(Optional) If you want to automatically create new private repositories in the tenancy's root compartment when
docker pushcommands don't include the name of an existing repository, follow these steps:
- Click Settings.
- Select Create repository on first push in root compartment.
Use the oci artifacts container repository create command and required parameters to create a repository:
oci artifacts container repository create --display-name <repo-name> --compartment-id <compartment_ocid> [OPTIONS]
oci artifacts container repository create --display-name project01/acme-web-app --compartment-id ocid1.compartment.oc1..aaaaaaaarvdfa72n...
For a complete list of flags and variable options for CLI commands, see the Command Line Reference.
Run the CreateContainerRepository operation to create a repository.