<?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: HiroItozzz</title>
    <description>The latest articles on DEV Community by HiroItozzz (@hiroitozzz).</description>
    <link>https://dev.to/hiroitozzz</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3724972%2F89436300-9ff6-4a01-9362-b78090231b04.png</url>
      <title>DEV Community: HiroItozzz</title>
      <link>https://dev.to/hiroitozzz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hiroitozzz"/>
    <language>en</language>
    <item>
      <title>I Published My First Python Package to PyPI — A CLI Tool for Docker Compose</title>
      <dc:creator>HiroItozzz</dc:creator>
      <pubDate>Sun, 03 May 2026 14:49:01 +0000</pubDate>
      <link>https://dev.to/hiroitozzz/i-published-my-first-python-package-to-pypi-a-cli-tool-for-docker-compose-l6o</link>
      <guid>https://dev.to/hiroitozzz/i-published-my-first-python-package-to-pypi-a-cli-tool-for-docker-compose-l6o</guid>
      <description>&lt;h1&gt;
  
  
  I Published My First Python Package to PyPI — A CLI Tool for Docker Compose
&lt;/h1&gt;

&lt;p&gt;I did it. I published my first package to PyPI.&lt;/p&gt;

&lt;p&gt;It's called &lt;strong&gt;fast-dcp&lt;/strong&gt;, and honestly, it started as a personal annoyance. I kept typing &lt;code&gt;docker compose up --build&lt;/code&gt; and &lt;code&gt;docker compose exec app bash&lt;/code&gt; dozens of times a day. My fingers got tired. So I built something about it.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is fast-dcp?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;fast-dcp&lt;/strong&gt; is a CLI tool that provides shorthand aliases for common &lt;code&gt;docker compose&lt;/code&gt; commands. Nothing revolutionary — just fewer keystrokes for the things you type constantly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Instead of this:&lt;/span&gt;
docker compose up &lt;span class="nt"&gt;--build&lt;/span&gt;

&lt;span class="c"&gt;# Just type:&lt;/span&gt;
dcpu &lt;span class="nt"&gt;-b&lt;/span&gt;

&lt;span class="c"&gt;# Instead of this:&lt;/span&gt;
docker compose &lt;span class="nb"&gt;exec &lt;/span&gt;app bash

&lt;span class="c"&gt;# Just type:&lt;/span&gt;
dcpe app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three commands cover the main workflows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;dcp&lt;/code&gt;&lt;/strong&gt; — general-purpose wrapper with subcommands (&lt;code&gt;up&lt;/code&gt;, &lt;code&gt;build&lt;/code&gt;, &lt;code&gt;exec&lt;/code&gt;, &lt;code&gt;restart&lt;/code&gt;, &lt;code&gt;ps&lt;/code&gt;, &lt;code&gt;logs&lt;/code&gt;, &lt;code&gt;stop&lt;/code&gt;, &lt;code&gt;down&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;dcpu&lt;/code&gt;&lt;/strong&gt; — dedicated shorthand for &lt;code&gt;docker compose up&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;dcpe&lt;/code&gt;&lt;/strong&gt; — dedicated shorthand for &lt;code&gt;docker compose exec&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Some real examples
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# docker compose up -d&lt;/span&gt;
dcp u &lt;span class="nt"&gt;-d&lt;/span&gt;

&lt;span class="c"&gt;# docker compose -f docker-compose.prod.yml up --build&lt;/span&gt;
dcpu &lt;span class="nt"&gt;-f&lt;/span&gt; docker-compose.prod.yml &lt;span class="nt"&gt;-b&lt;/span&gt;

&lt;span class="c"&gt;# docker compose exec app bash&lt;/span&gt;
dcpe app

&lt;span class="c"&gt;# docker compose exec app uv run pytest&lt;/span&gt;
dcpe app uv run pytest

&lt;span class="c"&gt;# docker compose restart app&lt;/span&gt;
dcp r app

&lt;span class="c"&gt;# docker compose logs app -f&lt;/span&gt;
dcp l app &lt;span class="nt"&gt;-F&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  How it's built
&lt;/h2&gt;

&lt;p&gt;The implementation is pure Python — no external runtime dependencies.&lt;/p&gt;

&lt;p&gt;The core is a &lt;code&gt;DockerCmdProcessor&lt;/code&gt; class that builds up the docker command from parsed arguments and passes it to &lt;code&gt;subprocess.run&lt;/code&gt;. It implements &lt;code&gt;__call__&lt;/code&gt;, so it works naturally as a callable passed to argparse's &lt;code&gt;set_defaults(func=...)&lt;/code&gt; — a pattern recommended in the argparse docs.&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;args&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse_args&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the CLI definition, I wrote a small &lt;code&gt;ArgDefiner&lt;/code&gt; wrapper around &lt;code&gt;ArgumentParser&lt;/code&gt; to enable method chaining. It made the &lt;code&gt;main()&lt;/code&gt; function much more declarative and readable — inspired by how Django's class-based views compose behavior through mixins.&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="p"&gt;(&lt;/span&gt;
    &lt;span class="nc"&gt;ArgDefiner&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;subparsers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_parser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;up&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;aliases&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;u&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;...))&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_project_args&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_file_args&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_build_args&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_detach_args&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_container_name_subcmd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;multiple&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set_defaults&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;func&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Processor&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Testing was surprisingly clean. Unit tests cover &lt;code&gt;ArgDefiner&lt;/code&gt; and &lt;code&gt;DockerCmdProcessor&lt;/code&gt; independently, and integration tests use &lt;code&gt;patch("sys.argv", ...)&lt;/code&gt; to simulate real CLI invocations end-to-end.&lt;/p&gt;




&lt;h2&gt;
  
  
  Install it
&lt;/h2&gt;

&lt;p&gt;No external runtime dependencies — pure Python. Just install and use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Using pipx (recommended)&lt;/span&gt;
pipx &lt;span class="nb"&gt;install &lt;/span&gt;fast-dcp

&lt;span class="c"&gt;# Or using uv&lt;/span&gt;
uv tool &lt;span class="nb"&gt;install &lt;/span&gt;fast-dcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Not familiar with pipx or uv?
&lt;/h3&gt;

&lt;p&gt;Both install CLI tools in isolated environments — no virtual environment activation needed, no conflicts with other packages. &lt;code&gt;uv tool&lt;/code&gt; is the faster option if you already use uv.&lt;/p&gt;

&lt;p&gt;macOS&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;pipx
pipx ensurepath
pipx &lt;span class="nb"&gt;install &lt;/span&gt;fast-dcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Windows&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;-m&lt;/span&gt; pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--user&lt;/span&gt; pipx
python &lt;span class="nt"&gt;-m&lt;/span&gt; pipx ensurepath
&lt;span class="c"&gt;# Restart terminal, then:&lt;/span&gt;
pipx &lt;span class="nb"&gt;install &lt;/span&gt;fast-dcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Linux (Ubuntu/Debian)&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;pipx
pipx ensurepath
pipx &lt;span class="nb"&gt;install &lt;/span&gt;fast-dcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Python 3.11+&lt;/li&gt;
&lt;li&gt;Docker with Compose V2 (&lt;code&gt;docker compose&lt;/code&gt;, not &lt;code&gt;docker-compose&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Honest thoughts on publishing for the first time
&lt;/h2&gt;

&lt;p&gt;This is a small tool. It wraps a handful of docker commands and saves a few keystrokes. But getting it to a point where someone else could &lt;code&gt;pipx install fast-dcp&lt;/code&gt; and have it just work — that took more thought than I expected.&lt;/p&gt;

&lt;p&gt;Packaging, &lt;code&gt;pyproject.toml&lt;/code&gt;, flit, classifiers, editable installs, &lt;code&gt;importlib.metadata&lt;/code&gt;... there's a lot of moving parts for something that feels like it should be simple. I learned a lot just by going through the process.&lt;/p&gt;

&lt;p&gt;If you work with docker compose regularly, give it a try. And if something is broken or missing, feel free to open an issue.&lt;/p&gt;

&lt;p&gt;🔗 &lt;a href="https://pypi.org/project/fast-dcp/" rel="noopener noreferrer"&gt;PyPI&lt;/a&gt; | &lt;a href="https://github.com/HiroItozzz/fast-dcp" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>python</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
