<?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>Forem: Rishav Sinha</title>
    <description>The latest articles on Forem by Rishav Sinha (@imrishav).</description>
    <link>https://forem.com/imrishav</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%2F226967%2F0af87af1-c5b5-4d7f-830f-60ea0a1c460a.jpeg</url>
      <title>Forem: Rishav Sinha</title>
      <link>https://forem.com/imrishav</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/imrishav"/>
    <language>en</language>
    <item>
      <title>Terraform Basic Command</title>
      <dc:creator>Rishav Sinha</dc:creator>
      <pubDate>Fri, 04 Feb 2022 18:49:43 +0000</pubDate>
      <link>https://forem.com/imrishav/terraform-basic-command-he2</link>
      <guid>https://forem.com/imrishav/terraform-basic-command-he2</guid>
      <description>&lt;h2&gt;
  
  
  What Exactly is Terraform IaC?
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Terraform is an open-source infrastructure as code software tool that enables you to safely and predictably create, change, and improve infrastructure.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is the definition that Hashicorp (Company working on Terraform) uses.&lt;/p&gt;

&lt;p&gt;But in simple terms Terraform is used as IaC to create , change and imporve resources provided on different cloud services with simply writing code that is it.&lt;/p&gt;

&lt;p&gt;Now let's understand this by a simple example.&lt;br&gt;
Suppose your company wants you to deploy a web app using some instances , a provisioned Database, some cloud functions etc.&lt;br&gt;
So traditionally you will go to cloud console (take AWS as example cause why not 😁) and enable services by order like creating the instance, using DB services and lamada's etc.&lt;/p&gt;

&lt;p&gt;This takes time and is pretty cumbersome to debug as we can miss step.&lt;/p&gt;

&lt;p&gt;So using IaC services such as Terraform we can simply write code to use the above said services and all the services will be deployed automatically, not only deploy if we want to delete or change some we can simply use the code for that. &lt;br&gt;
Trust me it very Simple and remove too many bottlenecks.&lt;/p&gt;

&lt;p&gt;So this is what Terraform is and it uses in a nutshell.&lt;/p&gt;

&lt;p&gt;Cool 😎 😎   now lets see some of the commands which are generally used and you will probably use regularly while working with Terraform&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Prerequisite&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Before starting make sure you have terraform installed using the following command
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tm44do-g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nnht4z9vyjstt86dqi9f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tm44do-g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nnht4z9vyjstt86dqi9f.png" alt="tf version" width="678" height="112"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now after verified that you have Terraform installed, create a new directory and create a file &lt;code&gt;main.tf&lt;/code&gt; this will host our first terraform code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2kTdRuNy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ddztl6yfio46zt29lto.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2kTdRuNy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ddztl6yfio46zt29lto.png" alt="file" width="380" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In that file put the code snippet, This snippet leverages the random provider, by HashiCorp registry, to generate a random string put name. Inside that we have optional parameters such as length. Here we're using &lt;code&gt;random&lt;/code&gt; , if we're using some cloud service we will use that here like instances, db recourses etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource "random_pet" "random" {
 length = 6
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3-YwWn2i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y7zbyl4l8es0prns5mzo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3-YwWn2i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y7zbyl4l8es0prns5mzo.png" alt="code" width="880" height="222"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;*&lt;em&gt;## * &lt;u&gt;LETS GET GOING WITH COMMANDS&lt;/u&gt;&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  1. &lt;strong&gt;init&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;init is quite similar to git init, basically initializing a new terraform workspace.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Fecqq9xE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8v0pu59djekktoui4taf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Fecqq9xE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8v0pu59djekktoui4taf.png" alt="Init" width="643" height="120"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After that terraform will communicate with the registry and fetch all the necessary resources metadata in this case the random provider&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xKt9-4vg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hq5ezxrbf7qqdlnf8gzw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xKt9-4vg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hq5ezxrbf7qqdlnf8gzw.png" alt="des" width="782" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As soon as this process completes you will see some changes in your folder structure.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9LOHL6_N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kprt4jo0u6rw13o28j1z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9LOHL6_N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kprt4jo0u6rw13o28j1z.png" alt="after init" width="377" height="622"&gt;&lt;/a&gt; &lt;/p&gt;




&lt;h3&gt;
  
  
  2. validate
&lt;/h3&gt;

&lt;p&gt;validate validates the configuration files in your workspace in our case ie &lt;code&gt;main.tf&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yIf1hIlq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6e0fe092fmrw6tl1nhnr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yIf1hIlq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6e0fe092fmrw6tl1nhnr.png" alt="Validate" width="880" height="154"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;If we have some syntax issue it will show up. See I have changed a resource parameter which is not valid. Running it again &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_DSKFUki--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oc9k7v3q85wclch1asiq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_DSKFUki--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oc9k7v3q85wclch1asiq.png" alt="No validated tf file" width="880" height="225"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  3. plan
&lt;/h3&gt;

&lt;p&gt;Now before making some actual changes to your infrastructure , we can "dry run" or check if every resource we specified in the configuration file is correct.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OMkM5jkf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/snaytgnj6wfyfmqexqh1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OMkM5jkf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/snaytgnj6wfyfmqexqh1.png" alt="plan tf" width="880" height="322"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  4. apply
&lt;/h3&gt;

&lt;p&gt;It is used to build the resources you planned for from your config file i.e. &lt;code&gt;main.tf&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will spit out the following output, we can put &lt;code&gt;yes&lt;/code&gt; to move further, terraform will built your random string resource based on&lt;br&gt;
what was in your plan file.&lt;/p&gt;

&lt;p&gt;Also you will see the output as well marked in the image in our case the pet name &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--miHNG_z4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hn261cmfsihx1fnreus.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--miHNG_z4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hn261cmfsihx1fnreus.png" alt="apply tf" width="880" height="433"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  4. destroy
&lt;/h3&gt;

&lt;p&gt;destroy as the name says destroy command is a easiest way to destroy all resource mentioned in the configuration. It does not delete your configuration file(s), &lt;code&gt;main.tf&lt;/code&gt;, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xFxJhnTV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5w8srhvdwsznhczve1zc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xFxJhnTV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5w8srhvdwsznhczve1zc.png" alt="Destroy" width="880" height="439"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;That's it folks, these are the basis and the most used Terraform commands, Please heart ❤️ if you like the content, will publish few more with some real life examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  ❄️ 
&lt;/h2&gt;

</description>
      <category>programming</category>
      <category>devops</category>
      <category>terraform</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Dockerfile Teardown</title>
      <dc:creator>Rishav Sinha</dc:creator>
      <pubDate>Wed, 11 Nov 2020 16:07:59 +0000</pubDate>
      <link>https://forem.com/imrishav/dockerfile-teardown-14jk</link>
      <guid>https://forem.com/imrishav/dockerfile-teardown-14jk</guid>
      <description>&lt;p&gt;So your app is ready, and now you want to containerize it using docker.If yes,then read on. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Docker file is a file which contains all commands that are required to generate an image.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Simple Docker file
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Feuwnob5b9k17etqy0ifg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Feuwnob5b9k17etqy0ifg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Creating a Docker file.
&lt;/h4&gt;

&lt;p&gt;In your project directory create a new file with the exact name Dockerfile.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnbsjawodmb1dj9p13hdu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnbsjawodmb1dj9p13hdu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inside this file only we will have all the commands listed.Lets see what are those commands.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. FROM
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM &amp;lt;image&amp;gt;:&amp;lt;tag&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Dockerfile must start with FROM. This basically sets the base image.&lt;/p&gt;

&lt;h6&gt;
  
  
  # Example
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM node:13-alpine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Instructed to get the base image of node with version 13.&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. LABEL
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LABEL &amp;lt;key&amp;gt;&amp;lt;value&amp;gt; &amp;lt;key2&amp;gt;&amp;lt;value2&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Used to set metadata for the image.It is a key-value pair&lt;/p&gt;

&lt;h6&gt;
  
  
  # Example
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LABEL companyname="xyz organization"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sets companyname label.You can access it using docker inspect &lt;/strong&gt;  &lt;/p&gt;

&lt;h4&gt;
  
  
  3. RUN
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RUN &amp;lt;command&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Executes command inside the new image and commits the results.&lt;/p&gt;

&lt;h6&gt;
  
  
  # Example
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RUN mkdir -p /home/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;This will create a new directory inside the image&lt;/strong&gt; &lt;/p&gt;

&lt;h4&gt;
  
  
  3. CMD
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CMD [&amp;lt;command&amp;gt;,&amp;lt;command&amp;gt;]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first commands to be executed after container is created. &lt;/p&gt;

&lt;h6&gt;
  
  
  # Example
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CMD ["npm", "start"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;This will execute &lt;code&gt;npm start&lt;/code&gt; when container is created.&lt;/strong&gt; &lt;/p&gt;

&lt;h4&gt;
  
  
  4. EXPOSE
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EXPOSE &amp;lt;port&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Informs Docker that the container listens on the specified network ports.This information is used to interconnect containers using links and to set up port redirection on the host system&lt;/p&gt;

&lt;h6&gt;
  
  
  # Example
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EXPOSE 3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;This will expose port inside the container as well as for host machine.&lt;/strong&gt; &lt;/p&gt;

&lt;h4&gt;
  
  
  5. ENV
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ENV &amp;lt;key&amp;gt;&amp;lt;value&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sets environment variables  to the value .This is passed to all &lt;code&gt;RUN&lt;/code&gt; , &lt;code&gt;CMD&lt;/code&gt; instructions&lt;/p&gt;

&lt;h6&gt;
  
  
  # Example
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ENV MONGO_DB_USERNAME=admin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Here MONGO_DB_USERNAME env is set to admin&lt;/strong&gt; &lt;/p&gt;

&lt;h4&gt;
  
  
  6. COPY
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;COPY &amp;lt;source&amp;gt; &amp;lt;destination&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copies files from source i.e the host into image.All new files &amp;amp; directories are created with mode 0755.&lt;/p&gt;

&lt;h6&gt;
  
  
  # Example
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;COPY ./package.json /home/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Here package.json file is being copied from current directory to /home/app in image.&lt;/strong&gt; &lt;/p&gt;

&lt;h4&gt;
  
  
  7. ADD
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ADD &amp;lt;source&amp;gt; &amp;lt;destination&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same as copy but some slight change.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The ADD instruction can copy and extract TAR files from the Docker host to the Docker image.&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  # Example
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ADD unzipthis.tar /home/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;This will extract files inside the image to the specified directory.&lt;/strong&gt; &lt;/p&gt;

&lt;h4&gt;
  
  
  8. VOLUME
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VOLUME &amp;lt;path&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Used for persistence inside docker images.This instruction  can create a directory inside the docker image, which can later be mounted to a directory&lt;/p&gt;

&lt;h6&gt;
  
  
  # Example
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VOLUME /data 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  9. WORKDIR
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WORKDIR &amp;lt;path&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instruction specifies what the working directory should be inside the Docker image&lt;/p&gt;

&lt;h6&gt;
  
  
  # Example
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WORKDIR /home/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;This will the directory where the RUN or other instruction will be executed.&lt;/strong&gt; &lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;Now try Reading this dockerfile again&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Feuwnob5b9k17etqy0ifg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Feuwnob5b9k17etqy0ifg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope this will make writing Dockerfile easier for you.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
