深深的思念 發表於 2021-5-10 11:30:00

Ubuntu安装Docker

<p>测试环境: Ubuntu desktop 16、Ubuntu Server 20</p>
<h2 id="安装docker">安装Docker</h2>
<p>由于apt官方库里的docker版本可能比较旧,所以先卸载可能存在的旧版本:</p>
<pre><code>sudo apt-get remove docker docker-engine docker-ce docker.io
</code></pre>
<p>更新apt包索引:</p>
<pre><code>sudo apt-get update
</code></pre>
<p>安装以下包以使apt可以通过HTTPS使用存储库(repository):</p>
<pre><code>sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
</code></pre>
<p>添加Docker官方的GPG密钥:</p>
<pre><code>curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
</code></pre>
<p>使用下面的命令来设置stable存储库:</p>
<pre><code>sudo add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
</code></pre>
<p>再更新一下apt包索引:</p>
<pre><code>sudo apt-get update
</code></pre>
<p>安装最新版本的Docker CE:</p>
<pre><code>sudo apt-get install -y docker-ce
</code></pre>
<h2 id="验证docker">验证docker</h2>
<p>查看docker服务是否启动:</p>
<pre><code>systemctl status docker
</code></pre>
<p>若未启动,则启动docker服务:</p>
<pre><code>sudo systemctl start docker
</code></pre>
<p>经典的hello world:</p>
<pre><code>sudo docker run hello-world
</code></pre>


</div>
<div id="MySignature" role="contentinfo">
    <p>作者:buildings<br>声明 :对于转载分享我是没有意见的,出于对博客园社区和作者的尊重请保留原文地址哈。<br>致读者 :坚持写博客不容易,写高质量博客更难,我也在不断的学习和进步,希望和所有同路人一道用技术来改变生活。觉得有点用就点个赞哈。</p><br><br>
来源:https://www.cnblogs.com/luengmingbiao/p/14750395.html
頁: [1]
查看完整版本: Ubuntu安装Docker