<?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>DEV Community: Sukhdev Thukral</title>
    <description>The latest articles on DEV Community by Sukhdev Thukral (@sukhdevth247).</description>
    <link>https://dev.to/sukhdevth247</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4070568%2Fbf72acb2-5cd4-4805-8255-e94a5aa6bd66.png</url>
      <title>DEV Community: Sukhdev Thukral</title>
      <link>https://dev.to/sukhdevth247</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sukhdevth247"/>
    <language>en</language>
    <item>
      <title>I used a bind mount to fix the biggest problem with Docker sandboxes</title>
      <dc:creator>Sukhdev Thukral</dc:creator>
      <pubDate>Mon, 10 Aug 2026 05:42:45 +0000</pubDate>
      <link>https://dev.to/sukhdevth247/i-used-a-bind-mount-to-fix-the-biggest-problem-with-docker-sandboxes-477i</link>
      <guid>https://dev.to/sukhdevth247/i-used-a-bind-mount-to-fix-the-biggest-problem-with-docker-sandboxes-477i</guid>
      <description>&lt;p&gt;Built repro, which is a one-command to open any GitHub issue in a Docker sandbox:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;repro-cli
repro https://github.com/expressjs/express/issues/3860
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First version cloned the repo &lt;em&gt;inside&lt;/em&gt; the container. Worked great until I typed &lt;code&gt;exit&lt;/code&gt; and lost everything I'd written. Container gone, files gone.&lt;/p&gt;

&lt;p&gt;The fix was obvious in hindsight: &lt;strong&gt;don't let the container own the files.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;host_dir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tempfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mkdtemp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prefix&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;repro-&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;owner&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;docker&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;run&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;--rm&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-v&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;host_dir&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;:/sandbox/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# files live on host, not in container
&lt;/span&gt;    &lt;span class="bp"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the repo clones into a real folder on your disk. The container temporarily borrows access to it. When you &lt;code&gt;exit&lt;/code&gt;, container dies, files stay.&lt;/p&gt;

&lt;p&gt;This also solved the editor problem for free, VS Code can open that real folder and attach directly to the container via the Dev Containers extension, so its terminal runs &lt;em&gt;inside&lt;/em&gt; the sandbox. One window, real editor, no split.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The one gotcha:&lt;/strong&gt; if you're cloning a private repo, the token can't go in the clone URL (it'd end up in &lt;code&gt;.git/config&lt;/code&gt; on your real disk in plaintext). So it goes via &lt;code&gt;--env-file&lt;/code&gt; instead — a temp file with &lt;code&gt;0o600&lt;/code&gt; permissions, deleted before you ever get a shell.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/SukhdevThukral/repro" rel="noopener noreferrer"&gt;https://github.com/SukhdevThukral/repro&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Curious to know what you'd have done differently.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>python</category>
      <category>devtools</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
