<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Docker on Tyler Collins</title>
    <link>https://www.tk11br.ca/tags/docker/</link>
    <description>Recent content in Docker on Tyler Collins</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>2022-2026 Tyler Collins. Content licensed under CC BY-NC 4.0.</copyright>
    <lastBuildDate>Wed, 26 Aug 2026 15:03:45 -0400</lastBuildDate>
    <atom:link href="https://www.tk11br.ca/tags/docker/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Turning a MATLAB EEG Pipeline Into a Container</title>
      <link>https://www.tk11br.ca/posts/matlab-eeg-pipeline-container-template/</link>
      <pubDate>Wed, 26 Aug 2026 15:03:45 -0400</pubDate>
      <guid>https://www.tk11br.ca/posts/matlab-eeg-pipeline-container-template/</guid>
      <description>A proof of concept using MATLAB Compiler, MATLAB Runtime, and Docker to package an EEGLAB analysis pipeline for another platform.</description>
      <content:encoded><![CDATA[<p>A MATLAB analysis pipeline can be battle-tested and still be difficult to share. The code can work, but the next platform may have the wrong MATLAB version, missing dependencies, or no MATLAB installation at all.</p>
<p>I put together a small <a href="https://github.com/Andesha/matlab-container-template">MATLAB container template</a> to show that you don&rsquo;t necessarily need to rewrite the analysis to solve this. MATLAB supports compiling a standalone application and packaging it as a Docker image. The deployed application runs with MATLAB Runtime rather than a full MATLAB installation.</p>
<h2 id="the-proof-of-concept">The proof of concept</h2>
<p>The example is an EEGLAB pipeline that loads a <code>.set</code> file, crops it to a time window, calculates power in five frequency bands, and writes the result to CSV. It isn&rsquo;t meant to do much, it&rsquo;s just enough to provide context.</p>
<p>The first step is to keep the analysis in an ordinary MATLAB function and test it inside MATLAB. The repository includes a known-good CSV so the result can be checked after every packaging step.</p>
<p>A thin command-line wrapper then validates the four expected arguments and calls the pipeline. That wrapper becomes the application&rsquo;s entry point. MATLAB Compiler builds it with one command:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-matlab" data-lang="matlab"><span class="line"><span class="cl"><span class="n">buildResults</span> <span class="p">=</span> <span class="n">compiler</span><span class="p">.</span><span class="n">build</span><span class="p">.</span><span class="n">standaloneApplication</span><span class="p">(</span> <span class="c">...</span>
</span></span><span class="line"><span class="cl">    <span class="s">&#39;eeglab_psd_cli.m&#39;</span><span class="p">,</span> <span class="c">...</span>
</span></span><span class="line"><span class="cl">    <span class="s">&#39;ExecutableName&#39;</span><span class="p">,</span> <span class="s">&#39;eeglab_psd_app&#39;</span><span class="p">);</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>MATLAB can then package that build as a Docker image with another command:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-matlab" data-lang="matlab"><span class="line"><span class="cl"><span class="n">compiler</span><span class="p">.</span><span class="n">package</span><span class="p">.</span><span class="n">docker</span><span class="p">(</span><span class="n">buildResults</span><span class="p">,</span> <span class="c">...</span>
</span></span><span class="line"><span class="cl">    <span class="s">&#39;ImageName&#39;</span><span class="p">,</span> <span class="s">&#39;eeglab-psd-app&#39;</span><span class="p">);</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>The final test mounts the sample data as read-only, mounts a separate output directory, runs the image, and compares the new CSV with the known-good result.</p>
<h2 id="the-boring-problem-that-still-matters">The boring problem that still matters</h2>
<p>File permissions were the main gotcha in this example. The application can run correctly and still fail because its output path isn&rsquo;t writable inside the container. Pipelines with an existing directory structure, such as BIDS workflows, need the same check for every location they write to.</p>
<p>That isn&rsquo;t specific to MATLAB, but it is easy to miss when the analysis itself has worked for years.</p>
<h2 id="this-is-already-an-option">This is already an option</h2>
<p>It was cool to see how little custom machinery it needed. The MATLAB Compiler and its Docker packaging support make container deployment a first-class path, not a workaround someone has to invent from scratch.</p>
<p>Now, a working MATLAB pipeline doesn&rsquo;t always need to become platform-independent source code with a new installation story. It may only need a clear command-line entry point, a known-good result, and a container.</p>
<p>The <a href="https://github.com/Andesha/matlab-container-template">template repository</a> has the complete functions and commands. The code snippets really are most of the process.</p>
]]></content:encoded>
    </item>
  </channel>
</rss>
