<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>gj |</title>
	<atom:link href="https://blog.gaiterjones.com/category/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.gaiterjones.com/category/ajax/</link>
	<description>gaiterjones</description>
	<lastBuildDate>Fri, 17 Mar 2017 15:02:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.3</generator>
	<item>
		<title>Running Docker Apps in Docker Containers &#8211; docker in docker permissions</title>
		<link>https://blog.gaiterjones.com/docker-in-docker-permissions/</link>
					<comments>https://blog.gaiterjones.com/docker-in-docker-permissions/#respond</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Fri, 17 Mar 2017 18:49:11 +0000</pubDate>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[docker in docker]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=1541</guid>

					<description><![CDATA[If you are looking at containerising PHP applications you might want to run another containerised application from within your container &#8211; run a docker application or command in a docker...<a class="more-link" href="https://blog.gaiterjones.com/docker-in-docker-permissions/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p>If you are looking at containerising PHP applications you might want to run another containerised application from within your container &#8211; run a docker application or command in a docker container. Your native app might be encoding media on the fly via ajax requests using ffpmeg and you do not want to compile or install ffmpeg in your containerised app. It would be useful to run a containerised ffmpeg version within the container.</p>
<p>This is kind of a <em>quasi docker in docker</em> because we are not trying to create dockerised containers within a container, rather run a docker app from the docker host within a docker container.</p>
<p>Still with me? Good!</p>
<p>We give our container access to the host docker socket by sharing a volume (in this case docker.sock) with the container</p>
<pre class="brush: plain; title: ; notranslate">
  volumes:    
      - /var/run/docker.sock:/var/run/docker.sock
</pre>
<p>If we install the docker binaries within the container we can now run docker commands on the host i.e.:</p>
<pre>root@53f93be9ebbf:/#<strong> docker ps</strong>
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAME S
53f93be9ebbf trusty_ubuntu "/bin/bash" 18 seconds ago Up 17 seconds...</pre>
<p>We are running docker ps as root, the problems start when you try and run docker as another user, for example www-data.</p>
<pre>root@53f93be9ebbf:/# sudo -u www-data docker ps
<strong>Got permission denied while trying to connect to the Docker daemon socket</strong> at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.26/containers/json: dial unix /var/run/docker.sock: connect: permission denied</pre>
<p>We get a <strong>dial unix /var/run/docker.sock: connect: permission denied </strong>error.</p>
<p>Even if you add www-data to the docker group the permission problem persists.</p>
<p>If you take a look at /var/run/docker.sock in the container you will see the problem:</p>
<pre>root@53f93be9ebbf:/# ls -al /var/run/docker.sock
srw-rw---- 1 root 999 0 Jan 26 08:55 /var/run/docker.sock</pre>
<p>The container shows the group permissions for docker.sock (from the host) set to a group with an id of 999, and this group id does not exist in the container. We need to make sure the group id of the docker group in the container matches the group id of the docker group on the host</p>
<pre>addgroup --gid 999 docker
usermod -aG docker www-data</pre>
<p>The docker group now has the id of 999 and www-data is a member, the permissions in the container for docker.sock now look like this</p>
<pre>root@53f93be9ebbf:/# ls -al /var/run/docker.sock
srw-rw---- 1 root docker 0 Jan 26 08:55 /var/run/docker.sock</pre>
<p>And we can now execute docker ps as www-data</p>
<pre>root@53f93be9ebbf:/# sudo -u www-data docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
53f93be9ebbf trusty_ubuntu "/bin/bash" 11 minutes ago Up 11 minutes ...</pre>
<p>Or run a <a href="https://github.com/jrottenberg/ffmpeg">containerised version of ffmpeg</a></p>
<pre>sudo -u www-data docker run jrottenberg/ffmpeg -stats \
 -i http://archive.org/download/thethreeagesbusterkeaton/Buster.Keaton.The.Three.Ages.ogv \
 -loop 0 \
 -final_delay 500 -c:v gif -f gif -ss 00:49:42 -t 5 - &gt; trow_ball.gif</pre>
<p><img fetchpriority="high" decoding="async" class="aligncenter size-large" src="https://blog.gaiterjones.com/dropbox/trow_ball.gif" width="400" height="300" /></p>
<p>I can now exec docker run within the php code of the container app and run other docker container apps via ajax requests. You can add the group changes and install the docker binaries in the container using the following in your Dockerfile.</p>
<pre class="brush: plain; title: ; notranslate">
# &gt;&gt;&gt; DOCKER IN DOCKER
RUN set -x \
    &amp;&amp; cd /tmp \
    &amp;&amp; curl -L -o docker-latest.tgz  https://get.docker.com/builds/Linux/x86_64/docker-latest.tgz \
    &amp;&amp; gzip -d docker-latest.tgz \
    &amp;&amp; tar -xvf docker-latest.tar \
    &amp;&amp; mv /tmp/docker/docker /usr/local/bin \
    &amp;&amp; rm -rf /tmp/docker docker-latest.tar \
    &amp;&amp; addgroup --gid 999 docker \
    &amp;&amp; usermod -aG docker www-data
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/docker-in-docker-permissions/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="http://archive.org/download/thethreeagesbusterkeaton/Buster.Keaton.The.Three.Ages.ogv" length="0" type="video/ogg" />

			</item>
		<item>
		<title>Ajaxx Tweet &#8211; send direct messages via Twitter from web apps using Ajax</title>
		<link>https://blog.gaiterjones.com/ajaxx-tweet-send-direct-messages-via-twitter-web-apps-using-ajax/</link>
					<comments>https://blog.gaiterjones.com/ajaxx-tweet-send-direct-messages-via-twitter-web-apps-using-ajax/#respond</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Mon, 21 Oct 2013 13:57:50 +0000</pubDate>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Twitter]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=1056</guid>

					<description><![CDATA[I wanted to be alerted when something changed in a Magento admin web application (new customer registration). I guess notifications by email are a little bit old fashioned and I...<a class="more-link" href="https://blog.gaiterjones.com/ajaxx-tweet-send-direct-messages-via-twitter-web-apps-using-ajax/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://blog.gaiterjones.com/wp-content/uploads/2013/10/ajaxtweet-icon.png"><img decoding="async" class="hang-2-column      alignnone" alt="ajaxtweet-icon" src="https://blog.gaiterjones.com/wp-content/uploads/2013/10/ajaxtweet-icon.png" width="154" height="154" /></a></p>
<p>I wanted to be alerted when something changed in a Magento admin web application (new customer registration). I guess notifications by email are a little bit old fashioned and I thought a Twitter DM notification would be a more up to date solution.</p>
<p>The PHP classes allow you to create Tweets or DM&#8217;s via an Ajax request as demonstrated <a href="http://tweet.ing-now.com/page/" target="_blank">here</a>.</p>
<p>It uses a simple JavaScript function to make an ajax call containing the data for the tweet. Can be used for any type of notification, app warnings, customer messages, contact forms, etc. etc. etc.</p>
<p>Source code coming to GitHub soon.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/ajaxx-tweet-send-direct-messages-via-twitter-web-apps-using-ajax/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PHP Application &#038; Ajax Request Security / Authentication</title>
		<link>https://blog.gaiterjones.com/php-application-ajax-request-security-authentication/</link>
					<comments>https://blog.gaiterjones.com/php-application-ajax-request-security-authentication/#comments</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Mon, 14 Oct 2013 13:56:49 +0000</pubDate>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=1048</guid>

					<description><![CDATA[I have been using Ajax a lot recently in my PHP applications, especially in my Magento interfaces to retrieve order and customer information. Working with Magento in PHP you need...<a class="more-link" href="https://blog.gaiterjones.com/php-application-ajax-request-security-authentication/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p>I have been using Ajax a lot recently in my PHP applications, especially in my <a title="Magento HTML Invoices, Print, Save, PDF" href="https://blog.gaiterjones.com/magento-html-invoices-print-save/">Magento interfaces</a> to retrieve order and customer information. Working with Magento in PHP you need to be careful you do not completely bypass Magento application security by creating open access to the Magento back end code via your PHP scripts, this is especially the case when using Ajax.</p>
<p>For a previous web site I looked at implementing best practice methods for implementing PHP session security and persistent login security for application logins. I revisited this code to create a PHP security class that I could quickly implement to add application login / persistent login security to a PHP app and additional authentication checks for Ajax requests.</p>
<p>The demo below shows the code in action, for login and Ajax authentication. Login using the demo username and password, then check the links out to read about the best practices implemented by the PHP class.</p>
<p>Source code on request.</p>
<p><strong> </strong></p>
<div class="iframe-container"><iframe src="https://blog.gaiterjones.com/dropdev/appsecurity/"></iframe></div>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/php-application-ajax-request-security-authentication/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Cross Browser Ajax / PHP File Uploader</title>
		<link>https://blog.gaiterjones.com/cross-browser-ajax-php-file-uploader/</link>
					<comments>https://blog.gaiterjones.com/cross-browser-ajax-php-file-uploader/#respond</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Tue, 02 Apr 2013 15:35:59 +0000</pubDate>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[File Uploader]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=924</guid>

					<description><![CDATA[&#160; &#160; A simple PHP ajax file uploader using XHR (HTML5) and Flash (Uploadify). Can be used as a plugin to provide cross browser file upload functionality. Can also email...<a class="more-link" href="https://blog.gaiterjones.com/cross-browser-ajax-php-file-uploader/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<p>&nbsp;</p>
<p><img decoding="async" class="hang-2-column     alignnone" alt="counter-icon" src="http://3.bp.blogspot.com/_qVbiC6HP35I/TMIJrxZ3mjI/AAAAAAAAAA8/5lg34GgyepI/S1600-R/Upload.png" width="161" height="161" />A simple PHP ajax file uploader using XHR (HTML5) and Flash (Uploadify). Can be used as a plugin to provide cross browser file upload functionality.</p>
<p>Can also email the upload as an attachment and has a built in translation system if required.</p>
<p><a href="https://github.com/gaiterjones/cross-browser-ajax-file-uploader" target="_blank">https://github.com/gaiterjones/cross-browser-ajax-file-uploader</a></p>
<div class="iframe-container"><iframe src="https://blog.gaiterjones.com/dropdev/git/cross-browser-ajax-file-uploader/demo.html"></iframe></div>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/cross-browser-ajax-php-file-uploader/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
