# Managing Repositories

A repository is an abstract folder you create within CCR, often so you can organize your images per team, business function, or deployment environment.

### Creating a Standard Repository

**CLI:**

```sh
crusoe registry repositories create \
  --name my-nginx-repo \
  --location us-east1-a \
  --mode standard
```

**UI:**

To create a standard repository using the [console](https://console.crusoecloud.com):

1. Go to the [Container Registry](https://console.crusoecloud.com/registry) page.
2. Click **Create Repository**.
3. Select **Standard** mode.
4. Click **Create**.

Your repository URL will be in the header details at the top of the page.

### Creating a Pull-Through Cache

A read-only cache for an upstream registry. When you pull an image, it is fetched from the upstream source, stored in your CCR repository, and then served.

#### Configuring Upstream Providers

When you create a repository in pull-through cache mode, you must specify an upstream registry `provider` and `url`, and if applicable, a `username` and `password`. Below are instructions for common upstream providers. Any Docker V2-compliant registries not explicitly listed should use `provider: docker-registry`.

| Registry Provider  | Example URL (must start with `http` or `https`) | `provider`        | `username`                                        | `password`                            |
| ------------------ | :---------------------------------------------- | :---------------- | :------------------------------------------------ | :------------------------------------ |
| Google Cloud (GAR) | `https://<region>-docker.pkg.dev`               | `google-gar`      | `_json_key`                                       | Entire service account JSON key file  |
| Google Cloud (GCR) | `https://gcr.io`                                | `google-gcr`      | `_json_key`                                       | Entire service account JSON key file  |
| AWS ECR (Private)  | `https://<id>.dkr.ecr.<region>.amazonaws.com`   | `aws-ecr`         | IAM user's access key ID                          | IAM user's secret key                 |
| AWS ECR Public     | `https://public.ecr.aws`                        | `docker-registry` | N/A                                               | N/A                                   |
| Docker Hub         | `https://hub.docker.com`                        | `docker-hub`      | `<dockerhub_username>`                            | `<personal_access_token>`             |
| GitHub (GHCR)      | `https://ghcr.io`                               | `github-ghcr`     | `<github_username>`                               | `<personal_access_token>`             |
| Azure (ACR)        | `https://<name>.azurecr.io`                     | `azure-acr`       | `<service_principal_id>` or `<access_token_name>` | `<client_secret>` or `<access_token>` |
| GitLab             | `https://registry.gitlab.com`                   | `docker-registry` | `<gitlab_username>`                               | `<personal_access_token>`             |
| NVIDIA NGC         | `https://nvcr.io`                               | `docker-registry` | `$oauthtoken`                                     | NGC API key                           |
| Oracle (OCI)       | `https://<region>.ocir.io`                      | `docker-registry` | `<your-namespace>/<username>`                     | OCI Registry Token                    |

**CLI:**

```sh
crusoe registry repositories create \
  --name my-dockerhub-cache \
  --location us-east1-a \
  --mode pull-through-cache \
  --upstream-registry \
      url=https://hub.docker.com,provider=docker-hub,username=myuser,password=mypass
```

To see all supported upstream registry providers, use `crusoe registry supported providers`.

**UI:**

To create a pull-through cache repository using the [console](https://console.crusoecloud.com):

1. Go to the [Container Registry](https://console.crusoecloud.com/registry) page.
2. Click **Create Repository**.
3. Select **Pull-through Cache** mode.
4. Select your upstream registry provider.
5. Enter your upstream registry URL and, optionally, your credentials.
6. Click **Create**.

Your repository URL will be in the header details at the top of the page.

### Listing and Getting Repository Details

**CLI:**

**List repositories in your project:**

```sh
crusoe registry repositories list
```

**Get details, including URL, for a specific repository:**

```sh
crusoe registry repositories get my-app-repo --location us-east1-a
```
**UI:**

To view all repositories in the [console](https://console.crusoecloud.com/registry), go to the [Container Registry](https://console.crusoecloud.com/registry) page.

### Deleting a Repository

A repository must be empty to be deleted. To delete images, see [managing images](managing-images.md#deleting-images).

**CLI:**

```sh
crusoe registry repositories delete my-app-repo --location us-east1-a
```
**UI:**

To delete a repository using the [console](https://console.crusoecloud.com):

1. Go to the [Container Registry](https://console.crusoecloud.com/registry) page.
2. Find the repository you want to delete.
3. Click the **Delete** icon next to the repository you want to delete.

### Repository URL Structure

CCR repository URLs follow a standard format of:

`registry.<location>.ccr.crusoecloudcompute.com/<repository-name>.<first-8-digits-of-project-id>`