<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>洛神丿红尘雪の小站</title>
  
  
  <link href="https://lshcx.github.io/atom.xml" rel="self"/>
  
  <link href="https://lshcx.github.io/"/>
  <updated>2024-09-20T01:29:07.000Z</updated>
  <id>https://lshcx.github.io/</id>
  
  <author>
    <name>洛神丿红尘雪</name>
    
  </author>
  
  <generator uri="https://hexo.io/">Hexo</generator>
  
  <entry>
    <title>docker入门（一）：docker安装</title>
    <link href="https://lshcx.github.io/posts/82e51b9c.html"/>
    <id>https://lshcx.github.io/posts/82e51b9c.html</id>
    <published>2024-09-20T01:29:07.000Z</published>
    <updated>2024-09-20T01:29:07.000Z</updated>
    
    <content type="html"><![CDATA[<h2 id="docker安装">docker安装</h2><h3 id="安装">安装</h3><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">sudo</span> apt update -y</span><br><span class="line"><span class="built_in">sudo</span> apt install docker.io docker-compose -y</span><br><span class="line"><span class="built_in">sudo</span> gpasswd -a username docker</span><br></pre></td></tr></tbody></table></figure><p><code>sudo apt update -y</code>: 使用<code>apt</code>包管理器更新系统的包列表。<br><code>sudo apt install docker docker-compose -y</code>:安装<code>docker</code>和<code>docker compose</code>，安装<code>docker.io</code>会自动将<code>containerd.io</code>、<code>docker-ce</code>、<code>docker-ce-cli</code> 都安装上。<br><code>sudo gpasswd -a username docker</code>: 将指定的用户（用实际用户名替换<code>username</code>）添加到<code>docker</code>用户组。加入<code>docker</code>组后用户可以在不使用<code>sudo</code>的情况下运行<code>docker</code>命令。</p><h3 id="查看是否安装成功">查看是否安装成功</h3><p>执行</p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker -v</span><br><span class="line">docker-compose -v</span><br></pre></td></tr></tbody></table></figure><p>输出对应的版本信息即安装成功</p><h2 id="常见问题">常见问题</h2><h3 id="ModuleNotFoundError-No-module-named-‘distutils’">ModuleNotFoundError: No module named ‘distutils’</h3><p>在最新版的Ubuntu遇到过一次，应该是版本问题导致<code>distutils</code>模块缺失，解决方法是卸载<code>docker-compose</code>然后安装<code>docker-compose-v2</code></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">sudo</span> apt remove docker-compose &amp;&amp; <span class="built_in">sudo</span> apt autoremove -y</span><br><span class="line"><span class="built_in">sudo</span> apt install docker-compose-v2 -y</span><br></pre></td></tr></tbody></table></figure><p>执行</p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker compose version</span><br></pre></td></tr></tbody></table></figure><p>输出docker compose版本即安装成功</p><div class="note warning modern"><p>使用docker compose v2版本后，docker-compose命令需要替换为docker compose，其他地方变化不大，可需要时再研究。</p></div>]]></content>
    
    
      
      
    <summary type="html">&lt;h2 id=&quot;docker安装&quot;&gt;docker安装&lt;/h2&gt;
&lt;h3 id=&quot;安装&quot;&gt;安装&lt;/h3&gt;
&lt;figure class=&quot;highlight bash&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre&gt;&lt;span class=&quot;li</summary>
      
    
    
    
    <category term="docker教程" scheme="https://lshcx.github.io/categories/docker%E6%95%99%E7%A8%8B/"/>
    
    
    <category term="docker" scheme="https://lshcx.github.io/tags/docker/"/>
    
    <category term="docker-compose" scheme="https://lshcx.github.io/tags/docker-compose/"/>
    
    <category term="Debian" scheme="https://lshcx.github.io/tags/Debian/"/>
    
    <category term="Ubuntu" scheme="https://lshcx.github.io/tags/Ubuntu/"/>
    
  </entry>
  
</feed>
