<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anubhav Sharma</title>
    <description>The latest articles on DEV Community by Anubhav Sharma (@anubhavs9).</description>
    <link>https://dev.to/anubhavs9</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F399192%2Fdc7932f1-cfe1-4498-8fb8-2fb70668b451.png</url>
      <title>DEV Community: Anubhav Sharma</title>
      <link>https://dev.to/anubhavs9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anubhavs9"/>
    <language>en</language>
    <item>
      <title>Share Docker Images - without Container Registry</title>
      <dc:creator>Anubhav Sharma</dc:creator>
      <pubDate>Mon, 28 Mar 2022 09:43:16 +0000</pubDate>
      <link>https://dev.to/anubhavs9/share-docker-images-without-container-registry-3jif</link>
      <guid>https://dev.to/anubhavs9/share-docker-images-without-container-registry-3jif</guid>
      <description>&lt;p&gt;Generally for running a docker container we first pull the required docker image/s from a container registry(CR), for ex- Github container registry, Docker Hub registry etc. This could be a publicly available image or a private one. Similarly we can push a newly built image to these registries.&lt;/p&gt;

&lt;p&gt;But what if we want to share an image that is currently stored in one machine to another machine or server without using a container registry.&lt;/p&gt;

&lt;p&gt;For this solution to work we need a shared storage or access to a cloud location or a file transfer capability between two machines(ex: SCP).&lt;/p&gt;




&lt;p&gt;Steps to share a Docker image:&lt;/p&gt;

&lt;p&gt;A. On first machine, build a new docker image or pull one from a container registry.&lt;/p&gt;

&lt;p&gt;B. Once the image is ready on first machine, save it in a .tar file in the local storage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker save -o &amp;lt;location-1&amp;gt;/image-name.tar image-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;C. Check if the new .tar file is saved in your local storage(location-1):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls &amp;lt;location-1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;D. Share this newly created .tar file to a location which is accessible by second machine. This could be a Cloud storage location on Azure, AWS etc, or a shared directory or simply 'scp' the file if its in a same network.&lt;/p&gt;

&lt;p&gt;E. Now save the new .tar file in  of second machine.&lt;br&gt;
Once the file is available on second machine we will load the image from that .tar file using below command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker load -i &amp;lt;location-2&amp;gt;/image-name.tar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;F. We can now check if the image is now available in the second machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;G. Now the image has been transferred successfully in your second machine without even using any container registry.&lt;/p&gt;

&lt;p&gt;This method works for both Linux and Windows based machines.&lt;/p&gt;




&lt;p&gt;Check official Docker documentation for more information.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Ref:&lt;br&gt;
&lt;a href="https://docs.docker.com/engine/reference/commandline/save/"&gt;https://docs.docker.com/engine/reference/commandline/save/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.docker.com/engine/reference/commandline/load/"&gt;https://docs.docker.com/engine/reference/commandline/load/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.docker.com/engine/reference/commandline/export/"&gt;https://docs.docker.com/engine/reference/commandline/export/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.docker.com/engine/reference/commandline/import/"&gt;https://docs.docker.com/engine/reference/commandline/import/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>containers</category>
      <category>development</category>
    </item>
  </channel>
</rss>
