<titledata-rh="true">Getting started with Compose | Podman Desktop</title><metadata-rh="true"name="viewport"content="width=device-width,initial-scale=1"><metadata-rh="true"name="twitter:card"content="summary_large_image"><metadata-rh="true"property="og:image"content="https://podman-desktop.io/img/banner_podman-desktop.png"><metadata-rh="true"name="twitter:image"content="https://podman-desktop.io/img/banner_podman-desktop.png"><metadata-rh="true"property="og:url"content="https://podman-desktop.io/tutorial/getting-started-with-compose"><metadata-rh="true"property="og:locale"content="en"><metadata-rh="true"name="docusaurus_locale"content="en"><metadata-rh="true"name="docsearch:language"content="en"><metadata-rh="true"name="docusaurus_version"content="current"><metadata-rh="true"name="docusaurus_tag"content="docs-tutorial-current"><metadata-rh="true"name="docsearch:version"content="current"><metadata-rh="true"name="docsearch:docusaurus_tag"content="docs-tutorial-current"><metadata-rh="true"property="og:title"content="Getting started with Compose | Podman Desktop"><metadata-rh="true"name="description"content="Getting started with Compose on Podman Desktop"><metadata-rh="true"property="og:description"content="Getting started with Compose on Podman Desktop"><metadata-rh="true"name="keywords"content="podman-desktop,compose,containers,containerfile,docker-compose,dockerfile,multi-container"><linkdata-rh="true"rel="icon"href="/img/favicon.ico"><linkdata-rh="true"rel="canonical"href="https://podman-desktop.io/tutorial/getting-started-with-compose"><linkdata-rh="true"rel="alternate"href="https://podman-desktop.io/tutorial/getting-started-with-compose"hreflang="en"><linkdata-rh="true"rel="alternate"href="https://podman-desktop.io/tutorial/getting-started-with-compose"hreflang="x-default"><linkdata-rh="true"rel="preconnect"href="https://MR01ANKQ9S-dsn.algolia.net"crossorigin="anonymous"><linkrel="alternate"type="application/rss+xml"href="/blog/rss.xml"title="Podman Desktop RSS Feed">
<linkrel="alternate"type="application/atom+xml"href="/blog/atom.xml"title="Podman Desktop Atom Feed">
<p><ahref="https://www.compose-spec.io/"target="_blank"rel="noopener noreferrer">Compose is a specification</a> for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services, networks, and volumes. This allows you to capture in a single file the entire configuration necessary to run a set of interconnected containers as an application. For example, if you have an application that requires a web server, a database, and a caching service, you can define these components and their relationships in your Compose file.</p>
<p>To use the Compose YAML, you can leverage a specification implementation, such as <ahref="https://docs.podman.io/en/latest/markdown/podman-compose.1.html"target="_blank"rel="noopener noreferrer"><code>podman compose</code></a> and <ahref="https://github.com/docker/compose"target="_blank"rel="noopener noreferrer"><code>docker compose</code></a>.</p>
<p>This tutorial covers the following end-to-end tasks required to use a multi-container Compose application within Podman Desktop:</p>
<ul>
<li><ahref="/tutorial/getting-started-with-compose#download-and-run-the-example-application">Download and run the example application</a> using <code>podman compose up</code>.</li>
<li><ahref="/tutorial/getting-started-with-compose#viewing-the-guestbook-application">View the guestbook web application</a>.</li>
<li><ahref="/tutorial/getting-started-with-compose#viewing-and-modifying-the-database">View and modify the database</a> to check the guestbook web application is synchronized and running correctly.</li>
<h2class="anchor anchorWithStickyNavbar_JmGV"id="before-you-begin">Before you begin<ahref="#before-you-begin"class="hash-link"aria-label="Direct link to Before you begin"title="Direct link to Before you begin"></a></h2>
<p>If you do not have Compose installed, you can follow the complete onboarding process to install it system wide:</p>
<ol>
<li>
<p>Install the Compose extension from the catalog. For more details, see <ahref="https://podman-desktop.io/docs/extensions/install"target="_blank"rel="noopener noreferrer">Installing a Podman Desktop extension</a>.</p>
</li>
<li>
<p>Set up Compose and complete the onboarding process to configure it system-wide.
<p>Check that you are able to run <code>podman compose</code>:</p>
<divclass="language-sh codeBlockContainer_mQmQ theme-code-block"style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><divclass="codeBlockContent_D5yF"><pretabindex="0"class="prism-code language-sh codeBlock_RMoD thin-scrollbar"style="color:#F8F8F2;background-color:#282A36"><codeclass="codeBlockLines_AclH"><spanclass="token-line"style="color:#F8F8F2"><spanclass="token function"style="color:rgb(80, 250, 123)">podman</span><spanclass="token plain"> compose</span><br></span><spanclass="token-line"style="color:#F8F8F2"><spanclass="token plain">Run compose workloads via an external provider such as </span><spanclass="token function"style="color:rgb(80, 250, 123)">docker-compose</span><spanclass="token plain"> or </span><spanclass="token function"style="color:rgb(80, 250, 123)">podman-compose</span><spanclass="token plain"></span><br></span><spanclass="token-line"style="color:#F8F8F2"><spanclass="token plain"style="display:inline-block"></span><br></span><spanclass="token-line"style="color:#F8F8F2"><spanclass="token plain">Description:</span><br></span><spanclass="token-line"style="color:#F8F8F2"><spanclass="token plain"> This </span><spanclass="token builtin class-name"style="color:rgb(189, 147, 249)">command</span><spanclass="token plain"> is a thin wrapper around an external compose provider such as </span><spanclass="token function"style="color:rgb(80, 250, 123)">docker-compose</span><spanclass="token plain"> or podman-compose. This means that </span><spanclass="token function"style="color:rgb(80, 250, 123)">podman</span><spanclass="token plain"> compose is executing another tool that implements the compose functionality but sets up the environment </span><spanclass="token keyword"style="color:rgb(189, 147, 249);font-style:italic">in</span><spanclass="token plain"> a way to </span><spanclass="token builtin class-name"style="color:rgb(189, 147, 249)">let</span><spanclass="token plain"> the compose provider communicate transparently with the </span><spanclass="token builtin class-name"style="color:rgb(189, 147, 249)">local</span><spanclass="token plain"> Podman socket. The specified options as well the </span><spanclass="token builtin class-name"style="color:rgb(189, 147, 249)">command</span><spanclass="token plain"> and argument are passed directly to the compose provider.</span><br></span><spanclass="token-line"style="color:#F8F8F2"><spanclass="token plain"></span><spanclass="token punctuation"style="color:rgb(248, 248, 242)">..</span><spanclass="token plain">.</span><br></span></code></pre><divclass="buttonGroup_aaMX"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_z5j7"aria-hidden="true"><svgviewBox="0 0 24 24"class="copyButtonIcon_FoOz"><pathfill="currentColor"d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgviewBox="0 0 24 24"class="copyButtonSuccessIcon_L0B6"><pathfill="currentColor"d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
</ol>
<divclass="theme-admonition theme-admonition-note admonition_WCGJ alert alert--secondary"><divclass="admonitionHeading_GCBg"><spanclass="admonitionIcon_L39b"><svgviewBox="0 0 14 16"><pathfill-rule="evenodd"d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><divclass="admonitionContent_pbrs"><p>If Compose is already installed, you have the option to upgrade or downgrade its version by navigating to the <strong>Settings > CLI Tools</strong> page.</p></div></div>
<h2class="anchor anchorWithStickyNavbar_JmGV"id="download-and-run-the-example-application">Download and run the example application<ahref="#download-and-run-the-example-application"class="hash-link"aria-label="Direct link to Download and run the example application"title="Direct link to Download and run the example application"></a></h2>
<p>Our example application is located at <ahref="https://github.com/redhat-developer/podman-desktop-demo"target="_blank"rel="noopener noreferrer">github.com/redhat-developer/podman-desktop-demo</a>.</p>
<ol>
<li>
<p>Run <code>git clone</code> to build the Go binary web application:</p>
<h2class="anchor anchorWithStickyNavbar_JmGV"id="viewing-the-guestbook-application">Viewing the guestbook application<ahref="#viewing-the-guestbook-application"class="hash-link"aria-label="Direct link to Viewing the guestbook application"title="Direct link to Viewing the guestbook application"></a></h2>
<p>Within Podman Desktop, you can now see that all three containers are up and operational.</p>
<ol>
<li>
<p>Click the "Open Browser" button to view the web application:
<p>Within the Guestbook web application, you can:</p>
<ul>
<li>
<p>"Sign" the guestbook, which will write to the Redis leader and synchronize to the replicas.</p>
</li>
<li>
<p>"Read" from the guestbook, which will read from the pool of Redis replicas. This allows for readability even if the Redis leader is unavailable.</p>
</li>
<li>
<p><code>/env</code>: View the container's environment variables.</p>
</li>
<li>
<p><code>/info</code>: View information about the Redis cluster.</p>
<h2class="anchor anchorWithStickyNavbar_JmGV"id="viewing-and-modifying-the-database">Viewing and modifying the database<ahref="#viewing-and-modifying-the-database"class="hash-link"aria-label="Direct link to Viewing and modifying the database"title="Direct link to Viewing and modifying the database"></a></h2>
<p>Using Podman Desktop, you can also access the container's terminal directly from the GUI and modify the database.</p>
<ol>
<li>
<p>Click <strong>Open Terminal</strong> to access the <code>redis-leader</code> terminal:</p>
<p>Changes will reflect in real-time on the guestbook.</p>
</li>
</ol>
</li>
</ol>
<p>You can further modify the database and see the changes propagate to the Redis replicas. For example, view the logs of the <code>redis-replica</code>, and you will notice that there are periodic database synchronizations as well as reads to the database:</p>
<h3class="anchor anchorWithStickyNavbar_JmGV"id="how-does-it-work">How does it work?<ahref="#how-does-it-work"class="hash-link"aria-label="Direct link to How does it work?"title="Direct link to How does it work?"></a></h3>
<p>A quick overview of how the architecture works in this multi-container scenario:</p>
<ul>
<li>Within the Guestbook application, it looks for a database with the names <code>redis-leader</code> and <code>redis-replica</code> on port <code>6379</code>.</li>
<li>Because it is a Compose application, the containers are connected on the same network. This means that a neighboring container can be network-accessible simply by its container name.</li>
</ul>
<p>There is a set of environment variables that the web application can modify in the Compose application:</p>
<ul>
<li><code>REDIS_LEADER</code>: The default is <code>redis-leader</code>.</li>
<li><code>REDIS_REPLICAS</code>: The default is <code>redis-replica</code>. It can be comma-separated, such as <code>redis-replica-1,redis-replica-2</code>.</li>
<li><code>REDIS_PORT</code>: The default is <code>6379</code>.</li>
<li><code>SERVER_PORT</code>: The default is <code>8080</code>.</li>
</ul>
<h2class="anchor anchorWithStickyNavbar_JmGV"id="scaling-more-replicas">Scaling more replicas<ahref="#scaling-more-replicas"class="hash-link"aria-label="Direct link to Scaling more replicas"title="Direct link to Scaling more replicas"></a></h2>
<p>Want to scale more replicas? This can be achieved by adding an environment variable to your <code>compose.yaml</code> and duplicating your <code>redis-replica</code> entry.</p>
<ol>
<li>
<p>Modify your <code>compose.yaml</code> as follows:</p>