- MyAccount
- Container Registry
- Copy Images From Other Registries
Create a replication rule
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.
Before you begin
Section titled “Before you begin”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.
Open the rule form
Section titled “Open the rule form”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.
Name the rule and choose the source
Section titled “Name the rule and choose the source”- 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.
- (Optional) In Description, add a note about what the rule copies.
- In Source registry, choose the source registry to copy from.
Choose how much of the path to keep
Section titled “Choose how much of the path to keep”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.
Choose when the rule runs
Section titled “Choose when the rule runs”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.
(Optional) Filter what is copied
Section titled “(Optional) Filter what is copied”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 underlibrary.1.0*matches tags that start with1.0.
Create the rule
Section titled “Create the rule”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.
Run the rule
Section titled “Run the rule”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 :
The copied images appear in your project’s repositories. If the rule or its run is refused, see Troubleshooting Container Registry.
Edit or turn off a rule
Section titled “Edit or turn off a rule”- 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.
- 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.
- Click Update.
Delete a rule
Section titled “Delete a rule”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.