Debian安装docker
<h1>Debian Docker 安装</h1><p>Docker 支持以下的 Debian 版本:</p>
<ul>
<li>Buster 10</li>
<li>Stretch 9 (stable) / Raspbian Stretch</li>
</ul>
<p>Docker Engine-Community 在 x86_64(或 amd64 )armhf,和 arm64 体系结构上受支持。</p>
<hr>
<h2>卸载旧版本</h2>
<p>Docker 的旧版本被称为 docker,docker.io 或 docker-engine,如果已安装,请卸载它们:</p>
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span> apt-get remove docker docker-engine docker.io containerd runc</pre>
</div>
<hr>
<h2>安装 Docker Engine-Community</h2>
<h3>使用 Docker 仓库进行安装</h3>
<p>在新主机上首次安装 Docker Engine-Community 之前,需要设置 Docker 仓库。之后,您可以从仓库安装和更新 Docker。</p>
<p>Raspbian 用户不能使用此方法!</p>
<p>对于 Raspbian,尚不支持使用仓库进行安装。您必须改为使用 shell 脚本方式。</p>
<h3>设置仓库</h3>
<p>更新 apt 包索引。</p>
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span> apt-get update</pre>
</div>
<p>安装 apt 依赖包,用于通过 HTTPS 来获取仓库。</p>
<div class="example">
<div class="example_code">
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span> apt-get <span style="color: rgba(0, 0, 255, 1)">install</span><span style="color: rgba(0, 0, 0, 1)"> \
apt</span>-transport-<span style="color: rgba(0, 0, 0, 1)">https \
ca</span>-<span style="color: rgba(0, 0, 0, 1)">certificates \
curl \
gnupg2 \
software</span>-properties-common</pre>
</div>
</div>
</div>
<p>添加 Docker 的官方 GPG 密钥:</p>
<div class="cnblogs_code">
<pre>$ curl -fsSL https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">download.docker.com/linux/debian/gpg | sudo apt-key add -</span></pre>
</div>
<p>9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 通过搜索指纹的后8个字符,验证您现在是否拥有带有指纹的密钥。</p>
<div class="example">
<div class="example_code">
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span> apt-key fingerprint 0EBFCD88</pre>
<p>pub 4096R/0EBFCD88 2017-02-22</p>
<pre> Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88<br>uid Docker Release (CE deb) <docker@docker.com><br>sub 4096R/F273FCD8 2017-02-22</pre>
</div>
使用以下指令设置稳定版仓库<br>
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span> add-apt-<span style="color: rgba(0, 0, 0, 1)">repository \
</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">deb https://download.docker.com/linux/debian \</span>
$(lsb_release -<span style="color: rgba(0, 0, 0, 1)">cs) \
stable</span><span style="color: rgba(128, 0, 0, 1)">"</span></pre>
</div>
</div>
</div>
<h3>安装 Docker Engine-Community</h3>
<p>更新 apt 包索引:</p>
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span> apt-get update</pre>
</div>
<p>安装最新版本的 Docker Engine-Community 和 containerd ,或者转到下一步安装特定版本:</p>
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span> apt-get <span style="color: rgba(0, 0, 255, 1)">install</span> docker-ce docker-ce-cli containerd.io</pre>
</div>
<p>要安装特定版本的 Docker Engine-Community,请在仓库中列出可用版本,然后选择一种安装。列出您的仓库中可用的版本:</p>
<div class="example">
<div class="example_code">
<div class="cnblogs_code">
<pre>$ apt-cache madison docker-<span style="color: rgba(0, 0, 0, 1)">ce
docker</span>-ce | <span style="color: rgba(128, 0, 128, 1)">5</span>:<span style="color: rgba(128, 0, 128, 1)">18.09</span>.<span style="color: rgba(128, 0, 128, 1)">1</span>~<span style="color: rgba(128, 0, 128, 1)">3</span>-<span style="color: rgba(128, 0, 128, 1)">0</span>~debian-stretch | https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">download.docker.com/linux/debian stretch/stable amd64 Packages</span>
docker-ce | <span style="color: rgba(128, 0, 128, 1)">5</span>:<span style="color: rgba(128, 0, 128, 1)">18.09</span>.<span style="color: rgba(128, 0, 128, 1)">0</span>~<span style="color: rgba(128, 0, 128, 1)">3</span>-<span style="color: rgba(128, 0, 128, 1)">0</span>~debian-stretch | https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">download.docker.com/linux/debian stretch/stable amd64 Packages</span>
docker-ce | <span style="color: rgba(128, 0, 128, 1)">18.06</span>.<span style="color: rgba(128, 0, 128, 1)">1</span>~ce~<span style="color: rgba(128, 0, 128, 1)">3</span>-<span style="color: rgba(128, 0, 128, 1)">0</span>~debian | https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">download.docker.com/linux/debian stretch/stable amd64 Packages</span>
docker-ce | <span style="color: rgba(128, 0, 128, 1)">18.06</span>.<span style="color: rgba(128, 0, 128, 1)">0</span>~ce~<span style="color: rgba(128, 0, 128, 1)">3</span>-<span style="color: rgba(128, 0, 128, 1)">0</span>~debian | https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">download.docker.com/linux/debian stretch/stable amd64 Packages</span>
...</pre>
</div>
</div>
</div>
<p>使用第二列中的版本字符串安装特定版本,例如 5:18.09.1~3-0~debian-stretch 。</p>
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span> apt-get <span style="color: rgba(0, 0, 255, 1)">install</span> docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io</pre>
</div>
<p>测试 Docker 是否安装成功,输入以下指令,打印出以下信息则安装成功:</p>
<div class="example">
<div class="example_code">
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span> docker run hello-<span style="color: rgba(0, 0, 0, 1)">world
Unable to </span><span style="color: rgba(0, 0, 255, 1)">find</span> image <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">hello-world:latest</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)"> locally
latest: Pulling from library</span>/hello-<span style="color: rgba(0, 0, 0, 1)">world
1b930d010525: Pull complete Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
Status: Downloaded newer image </span><span style="color: rgba(0, 0, 255, 1)">for</span> hello-<span style="color: rgba(0, 0, 0, 1)">world:latest
Hello from Docker</span>!<span style="color: rgba(0, 0, 0, 1)">
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
</span><span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)">. The Docker client contacted the Docker daemon.
</span><span style="color: rgba(128, 0, 128, 1)">2</span>. The Docker daemon pulled the <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">hello-world</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> image from the Docker Hub.
(amd64)
</span><span style="color: rgba(128, 0, 128, 1)">3</span>. The Docker daemon created a new container from that image <span style="color: rgba(0, 0, 255, 1)">which</span><span style="color: rgba(0, 0, 0, 1)"> runs the
executable that produces the output you are currently reading.
</span><span style="color: rgba(128, 0, 128, 1)">4</span>. The Docker daemon streamed that output to the Docker client, <span style="color: rgba(0, 0, 255, 1)">which</span><span style="color: rgba(0, 0, 0, 1)"> sent it
to your terminal.
To try something </span><span style="color: rgba(0, 0, 255, 1)">more</span><span style="color: rgba(0, 0, 0, 1)"> ambitious, you can run an Ubuntu container with:
$ docker run </span>-<span style="color: rgba(0, 0, 0, 1)">it ubuntu bash
Share images, automate workflows, and </span><span style="color: rgba(0, 0, 255, 1)">more</span> with a <span style="color: rgba(0, 0, 255, 1)">free</span><span style="color: rgba(0, 0, 0, 1)"> Docker ID:
https:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">hub.docker.com/</span>
<span style="color: rgba(0, 0, 0, 1)">
For </span><span style="color: rgba(0, 0, 255, 1)">more</span><span style="color: rgba(0, 0, 0, 1)"> examples and ideas, visit:
https:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">docs.docker.com/get-started/</span></pre>
</div>
</div>
</div><br><br>
来源:https://www.cnblogs.com/jiuzhongxian/p/12254892.html
頁:
[1]