doc: format markdown. 5a4f7cdf37

This commit is contained in:
jaywcjlove
2025-08-13 15:18:43 +00:00
parent 88bfebecb4
commit 1fdbb1b395
5 changed files with 31 additions and 29 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -44,17 +44,17 @@
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#入门">入门</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#docker-compose-是什么">Docker Compose 是什么?</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#基本概念">基本概念</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#docker-compose-文件结构">Docker-Compose 文件结构</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#安装">安装</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#独立安装-compose">独立安装 Compose</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#更新-compose">更新 Compose</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#卸载-docker-compose">卸载 Docker Compose</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#检查-compose-的安装位置">检查 Compose 的安装位置</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#常用命令">常用命令</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#常用运维命令">常用运维命令</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#其他命令">其他命令</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#docker-compose-配置">Docker Compose 配置</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#示例配置文件">示例配置文件</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#使用环境变量">使用环境变量</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#额外的信息">额外的信息</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#image">image</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#ports-端口">ports 端口</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#platform-平台">platform 平台</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#command">command</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#depends_on">depends_on</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#volumes">volumes</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#driver">driver</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#driver_opts">driver_opts</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#external">external</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#labels">labels</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#name">name</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#networks">networks</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#aliases">aliases</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#ipv4_address-ipv6_address">ipv4_address, ipv6_address</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#link_local_ips">link_local_ips</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#mac_address">mac_address</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#priority-优先级">priority 优先级</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#expose">expose</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#links">links</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#pids_limit">pids_limit</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#devices">devices</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#dns">dns</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#dns_opt">dns_opt</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#dns_search">dns_search</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="docker-compose-是什么"><a aria-hidden="true" tabindex="-1" href="#docker-compose-是什么"><span class="icon icon-link"></span></a>Docker Compose 是什么?</h3><div class="wrap-body">
<ul>
<li><code>Docker-compsoe</code> 是一个开源项目,用于定义和运行多容器 <code>Docker</code> 应用程序的工具。由 <code>Docker</code> 社区维护。</li>
<li>通过<code>YAML</code> 文件配置应用程序的服务,以便可以使用一命令启动、停止重启整个应用程序</li>
<li><strong>Docker Compose</strong> 是由 <a href="./docker.html">Docker</a> 社区维护的开源工具,用于定义和运行多容器应用</li>
<li>通过<a href="./yaml.html">YAML</a> 文件配置服务,可用一命令启动、停止重启整个应用。</li>
<li><a href="https://github.com/docker/compose">Docker Compose 开源地址</a></li>
<li><a href="https://github.com/docker/compose/releases">Docker Compose 发行地址</a> <em>github.com</em></li>
</ul>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="基本概念"><a aria-hidden="true" tabindex="-1" href="#基本概念"><span class="icon icon-link"></span></a>基本概念</h3><div class="wrap-body">
<ul>
<li><strong>服务 (services):</strong> 一个服务指的是一个容器,即一个应用程序的一个实例。</li>
<li><strong>容器 (container):</strong> <code>Docker</code> 容器,其中运行着应用程序的一个实例。</li>
<li><strong>镜像 (image):</strong> <code>Docker</code> 镜像,用于创建容器的模板。</li>
<li><strong>Docker-Compose 文件:</strong> 一个 <code>YAML</code> 文件,描述了应用程序的各个服务以及它们之间的关系、配置等信息。</li>
<li><strong>容器 (container):</strong> <a href="./docker.html">Docker</a> 容器,其中运行着应用程序的一个实例。</li>
<li><strong>镜像 (image):</strong> <a href="./docker.html">Docker</a> 镜像,用于创建容器的模板。</li>
<li><strong>Docker-Compose 文件:</strong> 一个 <a href="./yaml.html">YAML</a> 文件,描述了应用程序的各个服务以及它们之间的关系、配置等信息。</li>
</ul>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="docker-compose-文件结构"><a aria-hidden="true" tabindex="-1" href="#docker-compose-文件结构"><span class="icon icon-link"></span></a>Docker-Compose 文件结构</h3><div class="wrap-body">
<ul>
@@ -65,10 +65,10 @@
</ul>
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="安装"><a aria-hidden="true" tabindex="-1" href="#安装"><span class="icon icon-link"></span></a>安装</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->
<p>Docker 20.10 之后Docker CLI 支持 插件机制Compose 也被官方迁移为 CLI 插件。</p>
<p>命令也尽量使用官方推荐的 <code>docker compose</code> (<strong>中间用空格,没有横线</strong>)。建议尽早迁移,如果旧项目需要兼容 <code>docker-compose</code>,可单独安装 <code>docker-compose-plugin</code> 插件,或者是用软链接。</p>
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line"><span class="token function">sudo</span> <span class="token function">ln</span> <span class="token parameter variable">-s</span> /usr/lib/docker/cli-plugins/docker-compose /usr/local/bin/docker-compose
<p>Docker 20.10 起,CLI 支持插件机制,官方已将 Compose 迁移为 CLI 插件。推荐使用 <code>docker compose</code>(空格,无横线),旧项目如需兼容 <code>docker-compose</code> 可安装 <code>docker-compose-plugin</code> 或使用软链接。</p>
<pre class="wrap-text"><code class="language-bash code-highlight"><span class="code-line"><span class="token function">sudo</span> <span class="token function">ln</span> <span class="token parameter variable">-s</span> /usr/lib/docker/cli-plugins/docker-compose /usr/local/bin/docker-compose
</span></code></pre>
<!--rehype:className=wrap-text-->
<p>对于 Ubuntu 和 Debian运行</p>
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line"><span class="token function">sudo</span> <span class="token function">apt-get</span> update
</span><span class="code-line"><span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> docker-compose-plugin
@@ -255,12 +255,13 @@
<table class="left-align"><thead><tr><th>参数</th><th>说明</th></tr></thead><tbody><tr><td>-d / --detach</td><td>后台运行容器。</td></tr><tr><td>--remove-orphans</td><td>删除孤儿容器和网络配置。</td></tr><tr><td>--pull always</td><td>每次启动前都从远程仓库拉取最新镜像,确保使用最新镜像,而不是本地缓存。还可以用--pull missing只拉不存在的镜像或 --pull never不拉取</td></tr><tr><td>--force-recreate</td><td>强制重新创建容器,即使配置或镜像没有变化。</td></tr></tbody></table>
<table class="left-align"><thead><tr><th>参数</th><th>说明</th></tr></thead><tbody><tr><td><code>-d / --detach</code></td><td>后台运行容器。</td></tr><tr><td><code>--remove-orphans</code></td><td>删除孤儿容器和网络配置。</td></tr><tr><td><code>--pull always</code></td><td>每次启动前都从远程仓库拉取最新镜像,确保使用最新镜像,而不是本地缓存。还可以用--pull missing只拉不存在的镜像或 --pull never不拉取</td></tr><tr><td><code>--force-recreate</code></td><td>强制重新创建容器,即使配置或镜像没有变化。</td></tr></tbody></table>
<!--rehype:className=left-align-->
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="docker-compose-配置"><a aria-hidden="true" tabindex="-1" href="#docker-compose-配置"><span class="icon icon-link"></span></a>Docker Compose 配置</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="示例配置文件"><a aria-hidden="true" tabindex="-1" href="#示例配置文件"><span class="icon icon-link"></span></a>示例配置文件</h3><div class="wrap-body">
<!--rehype:wrap-class=col-span-2-->
<p><code>docker-compose</code> 的配置文件是一个 <code>YAML</code> 文件,用于定义和运行多容器 Docker 应用程序。通常命名为 <code>docker-compose.yml</code> (现在新的版本建议<code>compose.yaml</code> 代替之前的 <code>docker-compose.yaml</code>) ,它使用单一的 YAML 文件来定义多个容器的集合,以及它们之间的依赖关系和服务。以下是一份 <code>docker-compose.yml</code> 文件的配置模板,包含了常用配置项和解释:</p>
<p><code>docker-compose</code> 使用 <a href="./yaml.html">YAML</a> 文件定义和运行多容器应用,通常命名为 <code>docker-compose.yml</code>(新版本建议用 <code>compose.yaml</code>)。
该文件集中描述多个容器的服务、依赖关系等。下面是一个包含常用配置项和说明的模板:</p>
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">name</span><span class="token punctuation">:</span> myapp
</span><span class="code-line"><span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token string">'3'</span> <span class="token comment"># 已过时</span>
</span><span class="code-line">

File diff suppressed because one or more lines are too long

View File

@@ -1167,8 +1167,8 @@
<a href="https://github.com/catcto" title="小武Alan"><img src="https://avatars.githubusercontent.com/u/5467932?v=4" width="42;" alt="小武Alan"></a>
<a href="https://github.com/itldg" title="老大哥"><img src="https://avatars.githubusercontent.com/u/13432299?v=4" width="42;" alt="老大哥"></a>
<a href="https://github.com/wsypower" title="魏"><img src="https://avatars.githubusercontent.com/u/31298317?v=4" width="42;" alt="魏"></a>
<a href="https://github.com/buyfakett" title="buyfakett"><img src="https://avatars.githubusercontent.com/u/46560426?v=4" width="42;" alt="buyfakett"></a>
<a href="https://github.com/wangdaodao" title="王叨叨"><img src="https://avatars.githubusercontent.com/u/2317442?v=4" width="42;" alt="王叨叨"></a>
<a href="https://github.com/buyfakett" title="buyfakett"><img src="https://avatars.githubusercontent.com/u/46560426?v=4" width="42;" alt="buyfakett"></a>
<a href="https://github.com/AmosHuKe" title="Amos"><img src="https://avatars.githubusercontent.com/u/32262985?v=4" width="42;" alt="Amos"></a>
<a href="https://github.com/qjksxy" title="Apin"><img src="https://avatars.githubusercontent.com/u/81305669?v=4" width="42;" alt="Apin"></a>
<a href="https://github.com/BlacAmDK" title="BlacAmDK"><img src="https://avatars.githubusercontent.com/u/10971397?v=4" width="42;" alt="BlacAmDK"></a>
@@ -1176,14 +1176,13 @@
<a href="https://github.com/ljq" title="Jaco Liu"><img src="https://avatars.githubusercontent.com/u/7278286?v=4" width="42;" alt="Jaco Liu"></a>
<a href="https://github.com/jasnzhuang" title="Jason Zhuang"><img src="https://avatars.githubusercontent.com/u/16612921?v=4" width="42;" alt="Jason Zhuang"></a>
<a href="https://github.com/Jovins" title="Jovins"><img src="https://avatars.githubusercontent.com/u/17738992?v=4" width="42;" alt="Jovins"></a>
<a href="https://github.com/greyhao" title="greyhao"><img src="https://avatars.githubusercontent.com/u/107107440?v=4" width="42;" alt="greyhao"></a>
<a href="https://github.com/findnr" title="findnr"><img src="https://avatars.githubusercontent.com/u/217852450?v=4" width="42;" alt="findnr"></a>
<a href="https://github.com/izven" title="Zhang"><img src="https://avatars.githubusercontent.com/u/2149051?v=4" width="42;" alt="Zhang"></a>
<a href="https://github.com/Kisa-Dong" title="Kisa-Dong"><img src="https://avatars.githubusercontent.com/u/84782008?v=4" width="42;" alt="Kisa-Dong"></a>
<a href="https://github.com/SuperDiscovery" title="SuperDiscovery"><img src="https://avatars.githubusercontent.com/u/49646863?v=4" width="42;" alt="SuperDiscovery"></a>
<a href="https://github.com/ThanatosXingYu" title="Thanatos"><img src="https://avatars.githubusercontent.com/u/53430376?v=4" width="42;" alt="Thanatos"></a>
<a href="https://github.com/XYZscratcher" title="XYZ"><img src="https://avatars.githubusercontent.com/u/108533817?v=4" width="42;" alt="XYZ"></a>
<a href="https://github.com/izven" title="Zhang"><img src="https://avatars.githubusercontent.com/u/2149051?v=4" width="42;" alt="Zhang"></a>
<a href="https://github.com/findnr" title="findnr"><img src="https://avatars.githubusercontent.com/u/217852450?v=4" width="42;" alt="findnr"></a>
<a href="https://github.com/greyhao" title="greyhao"><img src="https://avatars.githubusercontent.com/u/107107440?v=4" width="42;" alt="greyhao"></a>
<a href="https://github.com/yanxuplay" title="hupilan"><img src="https://avatars.githubusercontent.com/u/69749541?v=4" width="42;" alt="hupilan"></a>
<a href="https://github.com/ThanatosXingYu" title="Thanatos"><img src="https://avatars.githubusercontent.com/u/53430376?v=4" width="42;" alt="Thanatos"></a>
<a href="https://github.com/hweining" title="hweining"><img src="https://avatars.githubusercontent.com/u/8973985?v=4" width="42;" alt="hweining"></a>
<a href="https://github.com/icer233" title="icer"><img src="https://avatars.githubusercontent.com/u/74440627?v=4" width="42;" alt="icer"></a>
<a href="https://github.com/auroraslot" title="irony"><img src="https://avatars.githubusercontent.com/u/48817882?v=4" width="42;" alt="irony"></a>
@@ -1199,6 +1198,8 @@
<a href="https://github.com/leauny" title="leauny"><img src="https://avatars.githubusercontent.com/u/42369176?v=4" width="42;" alt="leauny"></a>
<a href="https://github.com/liliangrong777" title="liliangrong777"><img src="https://avatars.githubusercontent.com/u/58727146?v=4" width="42;" alt="liliangrong777"></a>
<a href="https://github.com/lozhu20" title="lozhu"><img src="https://avatars.githubusercontent.com/u/44923922?v=4" width="42;" alt="lozhu"></a>
<a href="https://github.com/lykjjj" title="lykjjj"><img src="https://avatars.githubusercontent.com/u/58510058?v=4" width="42;" alt="lykjjj"></a>
<a href="https://github.com/yanxuplay" title="hupilan"><img src="https://avatars.githubusercontent.com/u/69749541?v=4" width="42;" alt="hupilan"></a>
<a href="https://github.com/hua03" title="hua03"><img src="https://avatars.githubusercontent.com/u/19561959?v=4" width="42;" alt="hua03"></a>
<a href="https://github.com/gzttcydxx" title="gzttcydxx"><img src="https://avatars.githubusercontent.com/u/50025185?v=4" width="42;" alt="gzttcydxx"></a>
<a href="https://github.com/sunny0826" title="Xudong Guo"><img src="https://avatars.githubusercontent.com/u/24563928?v=4" width="42;" alt="Xudong Guo"></a>
@@ -1214,8 +1215,7 @@
<a href="https://github.com/lijc210" title="cizai"><img src="https://avatars.githubusercontent.com/u/10651081?v=4" width="42;" alt="cizai"></a>
<a href="https://github.com/chyok" title="chyok"><img src="https://avatars.githubusercontent.com/u/32629225?v=4" width="42;" alt="chyok"></a>
<a href="https://github.com/cgluWxh" title="cgluWxh"><img src="https://avatars.githubusercontent.com/u/18211130?v=4" width="42;" alt="cgluWxh"></a>
<a href="https://github.com/eeeeeio" title="EEEEE"><img src="https://avatars.githubusercontent.com/u/20723545?v=4" width="42;" alt="EEEEE"></a>
<a href="https://github.com/lykjjj" title="lykjjj"><img src="https://avatars.githubusercontent.com/u/58510058?v=4" width="42;" alt="lykjjj"></a>
<a href="https://github.com/miclon-dev" title="miclon-dev"><img src="https://avatars.githubusercontent.com/u/111753685?v=4" width="42;" alt="miclon-dev"></a>
<a href="https://github.com/zhouhw0306" title="zhouhw0306"><img src="https://avatars.githubusercontent.com/u/82752681?v=4" width="42;" alt="zhouhw0306"></a>
<a href="https://github.com/zxx457" title="Xianxin Zeng"><img src="https://avatars.githubusercontent.com/u/114141362?v=4" width="42;" alt="Xianxin Zeng"></a>
<a href="https://github.com/lvzhenbo" title="无聊波波"><img src="https://avatars.githubusercontent.com/u/32427677?v=4" width="42;" alt="无聊波波"></a>
@@ -1232,7 +1232,6 @@
<a href="https://github.com/qwxingzhe" title="行者"><img src="https://avatars.githubusercontent.com/u/7071651?v=4" width="42;" alt="行者"></a>
<a href="https://github.com/binscor" title="binscor"><img src="https://avatars.githubusercontent.com/u/37325821?v=4" width="42;" alt="binscor"></a>
<a href="https://github.com/Zeng-qh" title="都一样"><img src="https://avatars.githubusercontent.com/u/40046415?v=4" width="42;" alt="都一样"></a>
<a href="https://github.com/miclon-dev" title="miclon-dev"><img src="https://avatars.githubusercontent.com/u/111753685?v=4" width="42;" alt="miclon-dev"></a>
<a href="https://github.com/notes-bin" title="notes-bin"><img src="https://avatars.githubusercontent.com/u/58727373?v=4" width="42;" alt="notes-bin"></a>
<a href="https://github.com/onewesong" title="onewesong"><img src="https://avatars.githubusercontent.com/u/17920822?v=4" width="42;" alt="onewesong"></a>
<a href="https://github.com/openapphub" title="openapphub"><img src="https://avatars.githubusercontent.com/u/175949671?v=4" width="42;" alt="openapphub"></a>
@@ -1248,6 +1247,8 @@
<a href="https://github.com/giteeking" title="xunjian"><img src="https://avatars.githubusercontent.com/u/166626162?v=4" width="42;" alt="xunjian"></a>
<a href="https://github.com/hiyms" title="yms"><img src="https://avatars.githubusercontent.com/u/84654050?v=4" width="42;" alt="yms"></a>
<a href="https://github.com/childeyouyu" title="youyu"><img src="https://avatars.githubusercontent.com/u/89082776?v=4" width="42;" alt="youyu"></a>
<a href="https://github.com/zcq100" title="zcq100"><img src="https://avatars.githubusercontent.com/u/425234?v=4" width="42;" alt="zcq100"></a>
<a href="https://github.com/eeeeeio" title="EEEEE"><img src="https://avatars.githubusercontent.com/u/20723545?v=4" width="42;" alt="EEEEE"></a>
<a href="https://github.com/sirius-fan" title="Fan"><img src="https://avatars.githubusercontent.com/u/25720015?v=4" width="42;" alt="Fan"></a>
<a href="https://github.com/Fuku-L" title="Foozi"><img src="https://avatars.githubusercontent.com/u/38535911?v=4" width="42;" alt="Foozi"></a>
<a href="https://github.com/Furry-Monster" title="Furry-Monster"><img src="https://avatars.githubusercontent.com/u/158404543?v=4" width="42;" alt="Furry-Monster"></a>
@@ -1811,7 +1812,7 @@
<li><a href="https://appstore.lazycat.cloud/#/shop/detail/io.zeroc.app.quickref">懒猫微服应用商店</a></li>
</ul>
</div></div><div class="h2wrap-body"></div></div></div></div><footer class="footer-wrap"><footer class="max-container">© 2022 <a href="https://wangchujiang.com/#/app" target="_blank">Kenny Wang</a>. Updated on 2025/08/13 22:20:38</footer></footer><script async src="https://www.googletagmanager.com/gtag/js?id=G-9MWEWXSDQK"></script><script>window.dataLayer = window.dataLayer || [];
</div></div><div class="h2wrap-body"></div></div></div></div><footer class="footer-wrap"><footer class="max-container">© 2022 <a href="https://wangchujiang.com/#/app" target="_blank">Kenny Wang</a>. Updated on 2025/08/13 23:17:37</footer></footer><script async src="https://www.googletagmanager.com/gtag/js?id=G-9MWEWXSDQK"></script><script>window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-9MWEWXSDQK');</script><script src="data.js?v=1.9.0" defer></script><script src="js/fuse.min.js?v=1.9.0" defer></script><script src="js/main.js?v=1.9.0" defer></script><div id="mysearch"><div class="mysearch-box"><div class="mysearch-input"><div><svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 18 18">