> ## Documentation Index
> Fetch the complete documentation index at: https://www.qovery.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Mirroring

> Optimize deployments with local image caching

When Qovery manages applications on your systems, it stores all generated container images in a registry on your cloud infrastructure. This feature is called image mirroring.

<img src="https://mintcdn.com/qovery/yDPPPWPKgIjFS10L/images/deployment/mirror-registry.png?fit=max&auto=format&n=yDPPPWPKgIjFS10L&q=85&s=6907b80e4ba4e861051d0e1fb4400d1a" alt="Mirror Registry" width="3164" height="2070" data-path="images/deployment/mirror-registry.png" />

## Why Image Mirroring?

Image mirroring serves two main purposes:

1. **Speed up deployments**: By caching built images, Qovery avoids rebuilding identical images, significantly accelerating the deployment process
2. **Secure scale-up operations**: When Kubernetes needs to scale up your application and create additional instances, having images stored locally ensures the operation succeeds even if the third-party registry is unavailable

## How It Works

The mirroring registry is accessible and configurable through the Qovery interface under the "Mirroring registry" section of your cluster.

### For Applications Built by Qovery CI

When Qovery builds your application from Git:

<img src="https://mintcdn.com/qovery/UjRUwWa_RXTarB-O/images/deployment/build-mirror.png?fit=max&auto=format&n=UjRUwWa_RXTarB-O&q=85&s=36868281fd55828601297e49dfcd6cbf" alt="Build and Mirror" width="3629" height="1330" data-path="images/deployment/build-mirror.png" />

1. After building, Qovery CI pushes the generated image to the mirroring registry
2. Images are organized by Git repository with naming: `z<short_cluster_id>-git_repo_name`
3. Image tags are derived from: commit ID, repository path, Dockerfile path, content, and ARGS variables
4. Before building, Qovery checks if a matching image already exists
5. If found, the build is skipped and the cached image is used
6. Unused images are automatically deleted when no longer referenced
7. Remote cache functionality (AWS, GCP, Scaleway) rebuilds only changed layers

### For Applications from Third-Party Registries

The behavior depends on the configured mirroring mode:

#### Service Mode (Default)

Each service maintains its own mirroring repository.

<img src="https://mintcdn.com/qovery/5PbLh8cgIXQeaRB1/images/deployment/image-mirror-service.png?fit=max&auto=format&n=5PbLh8cgIXQeaRB1&q=85&s=774fd51d8ae0bb81c531fb0aa9e277a2" alt="Service Mode" width="3629" height="1347" data-path="images/deployment/image-mirror-service.png" />

**Characteristics:**

* Images are organized per Qovery service (isolated processes)
* Automatic cleanup when images become unnecessary
* Downside: Identical images across services are mirrored multiple times

#### Cluster Mode

All applications on the same cluster share one mirroring repository.

<img src="https://mintcdn.com/qovery/5PbLh8cgIXQeaRB1/images/deployment/image-mirror-cluster.png?fit=max&auto=format&n=5PbLh8cgIXQeaRB1&q=85&s=6c710107d095ab7b3d3831df0c3b7909" alt="Cluster Mode" width="3629" height="1347" data-path="images/deployment/image-mirror-cluster.png" />

**Characteristics:**

* Reduces duplication for shared images across environments
* Requires manual image management via TTL settings
* Not available on Scaleway

## Important: Use Unique Image Tags

<Warning>
  Image tags must be unique. Both Qovery's mirroring system and Kubernetes employ caching mechanisms. Using the same tag for different image versions prevents new versions from deploying, causing applications to run outdated code.
</Warning>

Using tags like `latest` or other mutable tags can cause serious issues because the cached image in the mirroring registry may not be updated when you push a new version with the same tag.

**Best practices:**

* Use specific version tags: `myapp:v1.2.3`, `myapp:commit-abc123`
* Use immutable digests: `myapp@sha256:abc123...`
* Avoid mutable tags like `latest`, `stable`, or `prod`

## Disabling Mirroring

To skip mirroring operations, you can push your built images directly into the mirroring registry within repositories that match your image names.

Alternatively, if the source registry URL matches the cluster registry URL, mirroring is automatically skipped.

**Example for AWS:**

For an image `nginx` with cluster registry `https://32432542.dkr.ecr.eu-west-3.amazonaws.com`:

Push to: `https://32432542.dkr.ecr.eu-west-3.amazonaws.com/nginx`

## Image Retention Policy

Configurable TTL (Time To Live) settings control image retention duration via the advanced setting `image_retention_time`.

<Note>
  Modifications to the retention policy only affect newly created repositories. Existing repositories remain unchanged.
</Note>

## Next Steps

<CardGroup cols={2}>
  <Card title="Deployment Pipeline" icon="diagram-project" href="/configuration/deployment/pipeline">
    Configure deployment stages
  </Card>

  <Card title="Deployment Strategies" icon="chess" href="/configuration/deployment/strategies">
    Choose deployment strategy
  </Card>

  <Card title="Container Registry" icon="box" href="/configuration/organization/container-registry">
    Configure container registries
  </Card>

  <Card title="Deployment Actions" icon="gears" href="/configuration/deployment/actions">
    Manage deployment lifecycle
  </Card>
</CardGroup>
