<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Docker on Documentation</title><link>https://docs.ayshell.dev/tags/docker/</link><description>Recent content in Docker on Documentation</description><generator>Hugo -- 0.147.5</generator><language>en</language><lastBuildDate>Sat, 06 Sep 2025 18:55:00 +0530</lastBuildDate><atom:link href="https://docs.ayshell.dev/tags/docker/index.xml" rel="self" type="application/rss+xml"/><item><title>Docker: Persistent Storage Using Volumes</title><link>https://docs.ayshell.dev/posts/docker/volumes/</link><pubDate>Sat, 06 Sep 2025 18:55:00 +0530</pubDate><guid>https://docs.ayshell.dev/posts/docker/volumes/</guid><description>&lt;h1 id="what-are-docker-volumes">What are Docker Volumes?&lt;/h1>
&lt;p>Docker volumes are a mechanism for persisting data independently of the container lifecycle. Since, the data in a container will be deleted once the container is stopped, using Docker volumes ensures the data is stored permenently.&lt;/p>
&lt;ul>
&lt;li>Volumes are managed by Docker and stored on the host (mostly under &lt;code>/var/lib/docker/volumes&lt;/code>).&lt;/li>
&lt;li>Most importantly, it allows the data to be stored, retained and shared between container, suriving container restarts and removals.&lt;/li>
&lt;li>It preferrable to use for stateful applications like databases or file servers where data persistence matters.&lt;/li>
&lt;/ul>
&lt;h2 id="creating-and-using-volumes">Creating and Using Volumes&lt;/h2>
&lt;ul>
&lt;li>Volumes can be created implicitly by Docker when referenced or explicitly using:
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>docker volume create &amp;lt;volume_name&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>Start a container and mount a volume:
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>docker run -it -v &amp;lt;volume_name&amp;gt;:/path/in/container &amp;lt;image:tag&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;/ul>
&lt;h2 id="volume-content-persistence-and-sharing">Volume Content Persistence and Sharing&lt;/h2>
&lt;ul>
&lt;li>Files written/modified inside the container at the mount point path persist on the volume.&lt;/li>
&lt;li>When a new container mounts the same volume, it can process the previously stored data.&lt;/li>
&lt;li>Volumes can be mounted &lt;code>read-write&lt;/code> (&lt;em>default&lt;/em>) or &lt;code>read-only&lt;/code> with &lt;code>:ro&lt;/code> option:&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>docker run -it -v &amp;lt;volume_name&amp;gt;:/container/path/:ro &amp;lt;image:tag&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="inspecting-and-managing-volumes">Inspecting and Managing Volumes&lt;/h2>
&lt;ul>
&lt;li>List volumes:
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>docker volume ls
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>Inspect a volume for details like mount point:
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>docker volume inspect &amp;lt;volume_name&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>Remove a Volume(&lt;em>only when inactive/not being by any containers&lt;/em>)
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>docker volume rm &amp;lt;volume_name&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;/ul>
&lt;h1 id="thoughts">Thoughts&lt;/h1>
&lt;p>If you read this posts about &lt;a href="https://iamyaash.github.io/spells/posts/docker/mount-volume/">&lt;strong>Bind Mounts&lt;/strong>&lt;/a>, using Volumes over Bind Mount is a benefit because:&lt;/p></description></item><item><title>Docker: Using Bind Mounts (Volume Mount)</title><link>https://docs.ayshell.dev/posts/docker/mount-volume/</link><pubDate>Fri, 05 Sep 2025 14:50:04 +0530</pubDate><guid>https://docs.ayshell.dev/posts/docker/mount-volume/</guid><description>A short guide on mounting a local directory inside a container.</description></item><item><title>Docker: Build Multi-Architecture Container Images</title><link>https://docs.ayshell.dev/posts/docker/multi-arch-build/</link><pubDate>Tue, 05 Aug 2025 22:56:12 +0530</pubDate><guid>https://docs.ayshell.dev/posts/docker/multi-arch-build/</guid><description>A short guide to building and running container images for multiple architectures with instruction emulation.</description></item></channel></rss>