<?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 Emad Al-Shihabi on Medium]]></title>
        <description><![CDATA[Stories by Emad Al-Shihabi on Medium]]></description>
        <link>https://medium.com/@3emad?source=rss-98405fa469d0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nUR7H6MboOpyEyR_FrAv8A.png</url>
            <title>Stories by Emad Al-Shihabi on Medium</title>
            <link>https://medium.com/@3emad?source=rss-98405fa469d0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 23:11:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@3emad/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[My quick experiment with docker + vagrant]]></title>
            <link>https://medium.com/@3emad/my-quick-experiment-with-docker-vagrant-33e608a8c861?source=rss-98405fa469d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/33e608a8c861</guid>
            <dc:creator><![CDATA[Emad Al-Shihabi]]></dc:creator>
            <pubDate>Fri, 07 Nov 2014 04:11:09 GMT</pubDate>
            <atom:updated>2014-11-07T04:23:40.442Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*HUrNcG2_G82yTTOt8cWXww.png" /><figcaption>Docker Logo</figcaption></figure><h3>Quick experiment with docker + vagrant</h3><p>The hype by the tech community about how awesome docker is motivated me to try it out. a quick way I wanted to do it is through <a href="https://www.vagrantup.com/">vagrant</a> so I could delete it faster ( LIES! ).</p><p><strong>Objective -&gt; Install docker inside vagrant that serves nginx static files</strong></p><p><strong>Time -&gt; 5 mins</strong></p><p>Here is a quick walk-through of what I have done:</p><p><strong>1) </strong><a href="https://www.virtualbox.org/wiki/Downloads">install virtualbox</a> and <a href="https://www.vagrantup.com/downloads.html">install vagrant</a></p><p><strong>2) </strong>create a new file called <strong>”</strong><em>Vagrantfile</em><strong><em>” </em></strong>in your test directory which includes:</p><pre># -*- mode: ruby -*-<br># vi: set ft=ruby :</pre><pre><br># Config<br>server_ip = “10.1.1.34&quot;<br>server_memory = “512&quot; # MB<br>hostname	 = “docker.dev” # your ip server and hostname to /etc/hosts</pre><pre>VAGRANTFILE_API_VERSION = “2&quot;</pre><pre>Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|<br> config.vm.box = “ubuntu/trusty64&quot;<br> # config.vm.box_url = “http://files.vagrantup.com/precise64.box&quot;</pre><pre> # docker<br> config.vm.provision “docker”</pre><pre> # server ip<br> config.vm.network :private_network, ip: server_ip</pre><pre> # hostanme<br> config.vm.hostname = hostname</pre><pre> # If using VirtualBox<br> config.vm.provider :virtualbox do |vb|</pre><pre> # Set server memory<br> vb.customize [“modifyvm”, :id, “—memory”, server_memory]</pre><pre> # Set the timesync threshold to 10 seconds, instead of the default 20 minutes.<br> # If the clock gets more than 15 minutes out of sync (due to your laptop going<br> # to sleep for instance, then some 3rd party services will reject requests.<br> vb.customize [“guestproperty”, “set”, :id, “/VirtualBox/GuestAdd/VBoxService/—timesync-set-threshold”, 10000]<br> end</pre><pre> for i in 49000..49900<br> config.vm.network “forwarded_port”, guest: i, host: i<br> end<br>end</pre><p><strong>2) </strong>run <strong><em>“</em></strong><em>vagrant up</em><strong>”</strong></p><p><strong>3) </strong>access your docker ready dev. environment using <strong>“</strong><em>vagrant ssh</em><strong>”</strong></p><p><strong>4) </strong>at the vagrant home directory, I have created “nginx” folders which includes “html” folder and the docker configuration file called <strong>“</strong><em>Dockerfile</em><strong>” </strong>to build the docker image automatically which contains as Follows:</p><pre>FROM nginx</pre><pre>MAINTAINER Emad # your name<br>EXPOSE 80 # exposing port 80 for other docker containers</pre><pre>ADD ./html /usr/share/nginx/html # add the path to drive data from</pre><p><strong>5) </strong>running <strong>”</strong><em>docker build nginx .</em><strong>” </strong>which creates an image under name “nginx” ( taken “FROM nginx” docker configuration file )</p><p><strong>6) </strong>Finally! run he command that runs the container:</p><p><strong>“</strong><em>docker run — name nginx-run -v /home/vagrant/nginx/html:/usr/share/nginx/html -p 8080:80 -d nginx</em><strong>”</strong></p><p>explaining this step further:</p><ul><li><strong>“docker run” </strong>is the run command for docker container</li><li><strong>“ — name nginx-run” </strong>the name container given that your launching since you can lunch another container using the same image but different name and port</li><li><strong>“-v /home/vagrant/nginx/html:/usr/share/nginx/html” </strong>to mount the directory of the host to container destination path ( e.g &lt;host absolute directory&gt;:&lt;docker container absolute path&gt; ) note it must me absolute paths.</li><li><strong>“-p 8080:80&quot; </strong>this is to allow exposing the container ports to the host, this feature is exclusive to</li><li><strong>“-d” </strong>is to run the process in the background</li><li><strong>“nginx” </strong>is the name of the image we created earlier through build</li></ul><p>you could run another container using the same image with a different port with a different container name:</p><p><strong><em>“</em></strong><em>docker run — name nginx-run-another -v /home/vagrant/nginx/html:/usr/share/nginx/html -p 8081:80 -d nginx</em><strong><em>”</em></strong></p><p><strong>7) </strong>running “<em>docker ps” </em>should display something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6pdZ79UYTJq4DGO3.png" /></figure><p><strong>8) </strong>now lets write some test html file! go into “html” folder and run the following:</p><p><em>echo “&lt;h1&gt;Hello from docker!&lt;/h1&gt;” &gt; index.html</em></p><p><strong>9) </strong>now jump to your browser on your machine and go to <a href="http://10.1.1.34:8080/">http://10.1.1.34:8080</a> or <a href="http://docker.local:8080/">http://docker.local:8080</a> ( if you did the changes for the hosts file ) and you should be greeted by docker index.html</p><p>Congrats, you just ran your first docker container!</p><p><strong>Willing to jump into the next level?</strong></p><p><strong>First, </strong>try and edit your Vagrantfile to allow your host os to mount the actual vagrant html folder in nginx file ( e.g ~/nginx/html ) the end results would be to modify and fix files on docker machine from the main host os.</p><p><strong>Second, </strong>try using fig.sh to define multiple containers including load balancers and mysql and try to auto scale some of those container further using any of the following to <a href="http://stackoverflow.com/questions/18285212/how-to-scale-docker-containers-in-production">auto scale</a> something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x3K8lh0sXLvvRaqp.png" /></figure><p>Have fun!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33e608a8c861" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>