<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tharindu Abeysekara on Medium]]></title>
        <description><![CDATA[Stories by Tharindu Abeysekara on Medium]]></description>
        <link>https://medium.com/@sayatme.tharindu?source=rss-cc3e89a04bbb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bkZJdVhRXlZ-dotIWZvUWA.jpeg</url>
            <title>Stories by Tharindu Abeysekara on Medium</title>
            <link>https://medium.com/@sayatme.tharindu?source=rss-cc3e89a04bbb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 22:10:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sayatme.tharindu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automate your Docker Container Deployment with Terraform [for macOS]]]></title>
            <link>https://medium.com/@sayatme.tharindu/automate-your-docker-container-deployment-with-terraform-for-macos-ee2d98b6b422?source=rss-cc3e89a04bbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee2d98b6b422</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[infrastructure-automation]]></category>
            <category><![CDATA[macos]]></category>
            <dc:creator><![CDATA[Tharindu Abeysekara]]></dc:creator>
            <pubDate>Tue, 07 Sep 2021 21:52:01 GMT</pubDate>
            <atom:updated>2021-09-07T21:52:01.615Z</atom:updated>
            <content:encoded><![CDATA[<h3>Automate your Docker Container Deployment with Terraform [For Mac OS]</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_t3aveXd1dpE_d4_JxPN7w.png" /></figure><p>In this tutorial, we are going to install docker and terraform on your local computer and deploy an Nginx container.</p><p><strong>First, we are going to Install Terraform and Docker on your local pc.</strong></p><ul><li>Open your terminal and install HashiCorp on your MacBook.</li></ul><pre>$ brew tap hashicorp/tap</pre><ul><li>Then install Terraform using the below command.</li></ul><pre>$ brew install hashicorp/tap/terraform</pre><ul><li>To update the terraform to the latest version, first, you need to update Homebrew.</li></ul><pre>$ brew update</pre><ul><li>Then you can Update Terraform with the below command.</li></ul><pre>$ brew upgrade hashicorp/tap/terraform</pre><ul><li>Now you can verify your installation using the below command.</li></ul><pre>$ terraform -help</pre><p>If your installation is successful, you will see a similar result as the below screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/0*d1trcofhHlrKCfeV" /><figcaption>result of “terraform -help” command</figcaption></figure><ul><li>To Enable tab completion for auto-complete the commands. First, check for the config file on your shell.</li></ul><pre>$ touch ~/.bashrc</pre><ul><li>Then install the terraform autocomplete package using the below command.</li></ul><pre>$ terraform -install-autocomplete</pre><ul><li>Before we continue, you need to download and install the Docker Desktop for Mac from the below URL. [<a href="https://docs.docker.com/desktop/mac/install/#system-requirements"> System Requirements</a>]</li></ul><p>Download: <a href="https://docs.docker.com/docker-for-mac/install/">Docker Desktop for Mac</a></p><ul><li>After you install Docker on your computer run the below command to start Docker Desktop.</li></ul><pre>$ open -a Docker</pre><p><strong>Now you have successfully completed the Terraform and Docker installation.</strong></p><p><strong>Let’s see how we can automate the docker container deployment using terraform.</strong></p><ul><li>Create a new directory named “docker-with-terraform” using your terminal to keep your terraform configuration files.</li></ul><pre>$ mkdir docker-with-terraform</pre><ul><li>Then navigate into the newly-created directory.</li></ul><pre>$ cd docker-with-terraform</pre><ul><li>Using any text editor (vim/nano/etc.), create a new file named “main.tf”. In here I’m using nano editor.</li></ul><pre>$ nano main.tf</pre><ul><li>Then copy-paste the below configurations into main.tf and save it.</li></ul><pre>terraform {<br>   required_providers {<br>     docker = {<br>       source = “kreuzwerker/docker”<br>       version = “~&gt; 2.13.0”<br>     }<br>   }<br>}</pre><pre>provider “docker” {}</pre><pre>resource “docker_image” “nginx” {<br>   name = “nginx:latest”<br>   keep_locally = false<br>}</pre><pre>resource “docker_container” “nginx” {<br>   image = docker_image.nginx.latest<br>   name = “tutorial”<br>   ports {<br>     internal = 80<br>     external = 8080<br>    }<br>}</pre><ul><li>Use the below command to initialize a working directory containing Terraform configuration files. This is the first command that should be run after writing a new Terraform configuration. [<strong>You need to run this command inside the newly created directory where your “main.tf” file is saved.</strong>]</li></ul><pre>$ terraform init</pre><ul><li>Now we can Provision our Nginx container using the apply command. After you enter this command, Terraform will asks you to type “yes” and press ENTER to confirm.</li></ul><pre>$ terraform apply</pre><ul><li>If your terraform deployment is successful, you can see a “Apply complete!” message like in the below screenshot.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0lUcyARQCvy3DqR_eWJrYw.png" /><figcaption>result of the “terraform apply” command.</figcaption></figure><ul><li>Now go to your web browser and try to reach the below URL to verify the existence of the NGINX container. If you’re successful, You should see the Nginx welcome page as you can see in the below screenshot.</li></ul><pre><a href="http://localhost:8000/">localhost:80</a>80</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*afEXC4_5joeeCcWwZref4w.png" /><figcaption>nginx welcome page.</figcaption></figure><ul><li>And also you can see the details of the running container using the docker ps command.</li></ul><pre>$ docker ps</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6uu2_ZKVzlqRy54V56rIng.png" /></figure><h3>Congratulations!</h3><p>Now You have successfully deployed an Nginx container using terraform automation.</p><ul><li>You can stop the container using terraform destroy command.</li></ul><pre>$ terraform destroy</pre><p><em>Cheers..!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee2d98b6b422" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>