<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Bash on Humberto Rocha</title><link>https://humberto.io/tags/bash/</link><description>Recent content in Bash on Humberto Rocha</description><generator>Hugo</generator><language>en</language><lastBuildDate>Wed, 07 Dec 2022 11:28:01 -0500</lastBuildDate><atom:link href="https://humberto.io/tags/bash/index.xml" rel="self" type="application/rss+xml"/><item><title>Connect to a Kubernetes Pod</title><link>https://humberto.io/bits/connect-to-a-kubernetes-pod/</link><pubDate>Wed, 07 Dec 2022 00:00:00 +0000</pubDate><guid>https://humberto.io/bits/connect-to-a-kubernetes-pod/</guid><description>&lt;p&gt;To open a session it&amp;rsquo;s first required to know the Pod&amp;rsquo;s name.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#cdd6f4;background-color:#1e1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;kubectl get pod -n &amp;lt;namespace&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then open a bash session by running:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#cdd6f4;background-color:#1e1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;kubectl exec --stdin --tty &amp;lt;pod name&amp;gt; -n &amp;lt;namespace&amp;gt; -- /bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It&amp;rsquo;s also possible to open a shell session:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#cdd6f4;background-color:#1e1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;kubectl exec --stdin --tty &amp;lt;pod name&amp;gt; -n &amp;lt;namespace&amp;gt; -- /bin/sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Sometimes it&amp;rsquo;s need to spawn a new Pod from an image that has the required tooling to inspect something.&lt;/p&gt;</description></item><item><title>Interactive session in a Docker container</title><link>https://humberto.io/bits/interactive-session-in-a-docker-container/</link><pubDate>Tue, 22 Nov 2022 00:00:00 +0000</pubDate><guid>https://humberto.io/bits/interactive-session-in-a-docker-container/</guid><description>&lt;p&gt;Opening a bash session in a given container:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#cdd6f4;background-color:#1e1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker exec -it &amp;lt;container-name&amp;gt; /bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In case the image is more bare bones you can still open a shell session:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#cdd6f4;background-color:#1e1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker exec -it &amp;lt;container-name&amp;gt; /bin/sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;aside class="tip warning"&gt;
 You can only open sessions in containers that are running so check their status with &lt;code&gt;docker ps&lt;/code&gt; before trying to open the session.
&lt;/aside&gt;

&lt;p&gt;If you are not sure about the container names you can list them with:&lt;/p&gt;</description></item></channel></rss>