Skip to content

Create a replication rule

View as Markdown

A replication rule copies images from one source registry into your registry project, when you run it or on a schedule. The images always land in the project that holds the rule.

Add the source registry to this project first. If you are a team member, your role also needs the create permission for Container Registry. See Add a source registry.

In MyAccount, under Storage, click Container Registry, and click your project. Open its Replications Rules tab, headed Manage Replication Rules. Click + (New Replication Rules). Create Replication Rule opens.

  1. In Name, enter a name for the rule. It starts with a lowercase letter, uses the same characters as a project name, and must be unused in this project.
  2. (Optional) In Description, add a note about what the rule copies.
  3. In Source registry, choose the source registry to copy from.

Flattening Level sets how much of each image’s path at the source is kept in your project. For an image at a/b/c/d/img in the source registry:

Flattening Level Path in your project
Flatten All Levels <project-name>/img
No Flatting <project-name>/a/b/c/d/img
Flatten 1 Level <project-name>/b/c/d/img
Flatten 2 Levels <project-name>/c/d/img
Flatten 3 Levels <project-name>/d/img

A new rule starts at Flatten All Levels, which puts every image straight under your project. Choose No Flatting to keep the full source path, for example when two images at the source share a name in different folders.

In Trigger Mode, choose one:

  • Manual: the rule runs each time you click Execute. A new rule starts at Manual.
  • Scheduled: the rule runs on the schedule in Cron String, a five-field cron expression in UTC. The form spells the schedule out in words as you type. The string starts with the minute as a number; for example, 5 2 * * * runs the rule at 02:05 UTC every day.

Under Filters, limit the rule to some images. Name: matches image names. Tag: matches tags, and only Tag: has a choice of matching, to copy the tags that match, or excluding, to copy every other tag.

  • An empty value or ** matches everything.
  • library/** matches only what is under library.
  • 1.0* matches tags that start with 1.0.

Click Create. You see Replication Policy Created Successfully, and the rule is listed on the Replications Rules tab with its Name, Source Registry, State, Trigger Type, Description, and Updated Time. A new rule reads Enabled.

In MyAccount, under Storage, click Container Registry, click your project, and open its Replications Rules tab. Open the rule’s Actions menu and click Execute. A run starts, with Policy Execution Created Successfully. Execute runs a rule that reads Enabled; to run a disabled rule, turn it on first, as in Edit or turn off a rule.

To follow the run, click the rule. Executions : opens, with each run’s ID, Status, Trigger, and Start Time. A Failed run gives the reason it failed. To stop a run that reads InProgress, open its menu and click Stop.

The copied images appear in your project’s repositories. If the rule or its run is refused, see Troubleshooting Container Registry.

  1. In MyAccount, under Storage, click Container Registry, click your project, and open its Replications Rules tab. Open the rule’s Actions menu and click Edit. The rule form opens with Enable Rule added.
  2. Change the settings you need. To pause the rule, clear Enable Rule; to turn it back on, check it. Its State then reads Disabled or Enabled.
  3. Click Update.

In MyAccount, under Storage, click Container Registry, click your project, and open its Replications Rules tab. Open the rule’s Actions menu and click Delete. Confirm the prompt, which names the rule, to delete it.

Your project now copies images from the source registry by the rule you set. To remove images it no longer needs, see Clean up unused images.