Skip to content

Instantly share code, notes, and snippets.

@dmc5179
Last active May 6, 2026 19:15
Show Gist options
  • Select an option

  • Save dmc5179/82fdaa8fdbaa27c7712702eaa1994dfc to your computer and use it in GitHub Desktop.

Select an option

Save dmc5179/82fdaa8fdbaa27c7712702eaa1994dfc to your computer and use it in GitHub Desktop.
oc-mirror by catalog image index

oc mirror race condition workaround

  • Note: There is a race conditin in oc mirror during the mirror-to-disk process. If the index image changes, i.e a new one is published, between the time that oc mirror starts pulling images and the time oc mirror finishes, the resulting tar ball will be corrupted

  • HUGE WARNING: This process will has the index image listed by digest in your imageset-config.yaml. That works fine for mirror-to-disk run 1. When you want to update content you will want to do this again and get the digest of the latest version of the index image to put into the imageset-config.yaml. If that is NOT done, your imageset will become static.

Pull the index image

podman pull registry.redhat.io/redhat/redhat-operator-index:v4.20

Generate the index by digest instead of tag

export INDEX_IMAGE=$(echo "registry.redhat.io/redhat/redhat-operator-index@$(podman inspect registry.redhat.io/redhat/redhat-operator-index:v4.20 --format '{{.Digest}}')")
cat <<EOF > imageset-config.yaml
kind: ImageSetConfiguration
apiVersion: mirror.openshift.io/v2alpha1
mirror:
  platform:
    channels:
    - name: stable-4.20
      type: ocp
      minVersion: 4.20.18
      maxVersion: 4.20.18
    graph: true
  operators:
  - catalog: "${INDEX_IMAGE}"
    packages:
    - name: cincinnati-operator
      channels:
      - name: v1
EOF

Run mirror to disk process as normal

oc-mirror --v2 --config ./imageset-config.yaml file://${PWD}/mirror

Run the disk to mirror process as normal

  • Note: Make sure that when running disk-to-mirror that the imageset-config.yaml is the same as the mirror-to-disk and is using the catalog image digest value in both cases
oc-mirror -c ./imageset-config.yaml --from file:///home/<user>/oc-mirror/mirror1 docker://myregistry.com:6000 --v2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment