<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Python on Ashim Mahara</title><link>https://www.ashimmahara.com/tags/python/</link><description>Recent content in Python on Ashim Mahara</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 29 Jul 2026 01:27:31 -0400</lastBuildDate><atom:link href="https://www.ashimmahara.com/tags/python/index.xml" rel="self" type="application/rss+xml"/><item><title>Docker with Python</title><link>https://www.ashimmahara.com/writing/docker_python/</link><pubDate>Mon, 09 Feb 2026 00:00:00 +0000</pubDate><guid>https://www.ashimmahara.com/writing/docker_python/</guid><description>&lt;p&gt;Soooo, I have decided to write more about some of the things that I am doing right now.&lt;/p&gt;
&lt;p&gt;Today I decided to port my janky &lt;code&gt;subprocess.run(cmd)&lt;/code&gt; approach to managing docker containers to &lt;code&gt;docker-py&lt;/code&gt; sdk.&lt;/p&gt;
&lt;h2 id="client"&gt;Client&lt;/h2&gt;
&lt;p&gt;To interact with the local docker service, we first have to create a client.&lt;/p&gt;
&lt;p&gt;The client can be created as:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-python"&gt;import docker

client = docker.from_env()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There are other options available to for various configurations like providing the &lt;code&gt;DOCKER_HOST&lt;/code&gt; argument for remote hosts but I&amp;rsquo;ll leave it to you for reading up on it from &lt;a href="https://docker-py.readthedocs.io/en/stable/client.html"&gt;docker client ref&lt;/a&gt;.&lt;/p&gt;</description></item></channel></rss>