Answers: <p>Instead of transferring the images as a packaged tar file, I'd recommend using the <a href="https://github.com/opencontainers/image-spec/blob/main/image-layout.md" rel="nofollow noreferrer">OCI Image Layout</a> format that represents a repository as a directory on disk. Copying contents into or out of this directory can then leverage layer deduplication in the content addressable store. You'll need to ensure the same disk is reused each time you transfer the content to avoid downloading layers that were previously pulled.</p>
  <p>There are several tools that are able to work with images in this format. The ones I'm aware of are <a href="https://github.com/oras-project/oras" rel="nofollow noreferrer">ORAS</a> (originally from Microsoft), <a href="https://github.com/containers/skopeo" rel="nofollow noreferrer">skopeo</a> (from RedHat), and <a href="https://github.com/regclient/regclient/" rel="nofollow noreferrer">regclient</a> (my own project).</p>
  <p>Here's an example of what this would look like with regclient's regctl command:</p>
  <pre class="lang-shell prettyprint-override"><code># copy to disk
  regctl image copy ${public_repo}:${tag} ocidir://path/to/disk:${tag}
  
  # transfer the disk across the air-gap
  
  # copy from disk to internal registry
  regctl image copy ocidir://path/to/disk:${tag} ${private_repo}:${tag}
  </code></pre>
  <p>If you have a lot of images, the regclient/regsync command is probably what you are looking for.</p>
  
Answers: CC BY-SA 4.0
Answers: 2023-11-05T18:38:15.073Z
Answers: 2023-11-05T18:38:15.073Z
Answers: BMitch
Body: <p>I need to efficiently copy Docker images between two air gapped repositories. The current method of saving images to disk and transferring them as tarballs is time-consuming, so I am looking for a process that will:</p>
  <ol>
  <li>Eliminate redundant image layers by only copying each layer once, even if it is used by multiple images.</li>
  <li>Avoid copying layers that already exist in the remote repository.</li>
  </ol>
  <p>Is this possible? How can I do it?</p>
  
Tags: <docker><docker-registry>
Title: How to efficiently copy multiple Docker images between two air gapped repositories?
UserDisplayName: Sergey
ThreadText: # How to efficiently copy multiple Docker images between two air gapped repositories?
  
  (Asked by: username_0 on 2023-11-03)
  
  I need to efficiently copy Docker images between two air gapped repositories. The current method of saving images to disk and transferring them as tarballs is time-consuming, so I am looking for a process that will:
  
  1. Eliminate redundant image layers by only copying each layer once, even if it is used by multiple images.
  2. Avoid copying layers that already exist in the remote repository.
  
  Is this possible? How can I do it?
  
  **Tags:** docker, docker-registry
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-11-05. Score: 1 | Accepted answer
  
  Instead of transferring the images as a packaged tar file, I'd recommend using the [OCI Image Layout](https://github.com/opencontainers/image-spec/blob/main/image-layout.md) format that represents a repository as a directory on disk. Copying contents into or out of this directory can then leverage layer deduplication in the content addressable store. You'll need to ensure the same disk is reused each time you transfer the content to avoid downloading layers that were previously pulled.
  
  There are several tools that are able to work with images in this format. The ones I'm aware of are [ORAS](https://github.com/oras-project/oras) (originally from Microsoft), [skopeo](https://github.com/containers/skopeo) (from RedHat), and [regclient](https://github.com/regclient/regclient/) (my own project).
  
  Here's an example of what this would look like with regclient's regctl command:
  
  ```shell
  # copy to disk
  regctl image copy ${public_repo}:${tag} ocidir://path/to/disk:${tag}
  
  # transfer the disk across the air-gap
  
  # copy from disk to internal registry
  regctl image copy ocidir://path/to/disk:${tag} ${private_repo}:${tag}
  
  ```
  
  If you have a lot of images, the regclient/regsync command is probably what you are looking for.
  
  
  ---
  
  