<?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 Shane Johnson on Medium]]></title>
        <description><![CDATA[Stories by Shane Johnson on Medium]]></description>
        <link>https://medium.com/@shane.johnson?source=rss-fddd238fc95c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0eedH2LqVVL4fpH6j2KXcQ.jpeg</url>
            <title>Stories by Shane Johnson on Medium</title>
            <link>https://medium.com/@shane.johnson?source=rss-fddd238fc95c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 15 May 2026 16:11:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shane.johnson/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[SSH forwarding in a docker build context]]></title>
            <link>https://medium.com/@shane.johnson/ssh-forwarding-in-a-docker-build-context-f568bb7a53a6?source=rss-fddd238fc95c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f568bb7a53a6</guid>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[ssh-forwarding]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Shane Johnson]]></dc:creator>
            <pubDate>Fri, 26 Jan 2018 09:10:32 GMT</pubDate>
            <atom:updated>2018-01-26T09:10:32.885Z</atom:updated>
            <content:encoded><![CDATA[<p>If, like me, you like to have your complete javascript build done during the docker build phase, then you may have inevitably, come across the issue of needing to either npm install, yarn install or git checkout from a ssh connected location. At the time that I first encountered this problem I searched google and came across a few examples:</p><ul><li><a href="https://farazdagi.com/2016/using-ssh-private-keys-securely-when-building-docker-images/">Using SSH private keys securely when building Docker images</a></li><li><a href="https://dchua.com/2016/01/15/ssh-agent-forwarding-with-your-docker-container/">SSH Agent Forwarding with your Docker Container</a></li></ul><p>None of these examples seemed to suit my use case or just didn’t seem to work.</p><p>So I decided to go back to the drawing board and figure this out myself. It turns out that it is actually quite simple. The documentation for this is pretty much the same as the standard docs you would find for <a href="https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/">creating SSH keys for github and adding them to the SSH agent</a>. My use case was probably special — I had no intention of the build being triggered on a build server so I wasnt worried about accessing the SSH key and I only really wanted <em>my</em> SSH key to be used and also the <strong><em>docker build</em></strong> command was triggered from a <strong><em>yarn start</em></strong> command so I was able to do something special <em>before</em> the docker build process started.</p><p>My yarn start command started by triggering a shell file that copied my .ssh folder into the root of my project:</p><pre>cp -r ~/.ssh .ssh</pre><p>This got my ssh keys into my project so now it was just a matter of using these files as part of my docker build.</p><pre>WORKDIR /tmp</pre><pre>COPY .ssh .ssh</pre><pre>WORKDIR /</pre><pre>RUN cp -r /tmp/.ssh ~/.ssh<br>RUN eval &quot;$(ssh-agent -s)&quot;</pre><pre># do any other ssh dependant stuff you want</pre><pre># clean things up<br>RUN rm -rf /tmp</pre><p>So then on doing a <strong>docker build</strong> command I would have the ssh-agent at my disposal to do any SSH specific stuff that I wanted and then at the end of the build to be extra tidy and not have my ssh keys lying around in my project:</p><pre>rm -rf .ssh</pre><p>Like I said this work flow worked for my use case, which was using a docker container to contain a test environment for local testing — but every use case is different and this may not work for you. But in sharing this, I hope that it does and at least someone out there will find the useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f568bb7a53a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>