centos下docker安装
<h3>一、设置存储库</h3><div class="cnblogs_Highlighter">
<pre class="brush:bash;gutter:true;">yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
</pre>
</div>
<p> 执行结果</p>
<div class="cnblogs_Highlighter">
<pre class="brush:bash;gutter:true;">已加载插件:fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo<br>repo saved to /etc/yum.repos.d/docker-ce.repo
</pre>
</div>
<h3> </h3>
<h3>二、安装docker-ce(docker-ce是社区免费版,docker-ee是企业版)</h3>
<div class="cnblogs_Highlighter">
<pre class="brush:bash;gutter:true;">yum install -y docker-ce
</pre>
</div>
<p> 出现错误</p>
<div class="cnblogs_Highlighter">
<pre class="brush:bash;gutter:true;">获取 GPG 密钥失败: curl#35 - "Network file descriptor is not connected"
</pre>
</div>
<p>到http://mirrors.163.com找到对应版本</p>
<div class="cnblogs_Highlighter">
<pre class="brush:bash;gutter:true;">rpm --import http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
</pre>
</div>
<p>再次安装docker-ce成功</p>
<p> </p>
<h3>三、启动docker</h3>
<div class="cnblogs_Highlighter">
<pre class="brush:bash;gutter:true;">systemctl daemon-reload && systemctl start docker
</pre>
</div>
<p> 验证</p>
<div class="cnblogs_Highlighter">
<pre class="brush:bash;gutter:true;">docker version
</pre>
</div>
<p> </p>
<div class="cnblogs_code">
<pre>Client: Docker Engine -<span style="color: rgba(0, 0, 0, 1)"> Community
Version: </span><span style="color: rgba(128, 0, 128, 1)">19.03</span>.<span style="color: rgba(128, 0, 128, 1)">7</span><span style="color: rgba(0, 0, 0, 1)">
API version: </span><span style="color: rgba(128, 0, 128, 1)">1.40</span><span style="color: rgba(0, 0, 0, 1)">
Go version: go1.</span><span style="color: rgba(128, 0, 128, 1)">12.17</span><span style="color: rgba(0, 0, 0, 1)">
Git commit: 7141c199a2
Built: Wed Mar</span><span style="color: rgba(128, 0, 128, 1)">4</span> <span style="color: rgba(128, 0, 128, 1)">01</span>:<span style="color: rgba(128, 0, 128, 1)">24</span>:<span style="color: rgba(128, 0, 128, 1)">10</span> <span style="color: rgba(128, 0, 128, 1)">2020</span><span style="color: rgba(0, 0, 0, 1)">
OS</span>/Arch: linux/<span style="color: rgba(0, 0, 0, 1)">amd64
Experimental: </span><span style="color: rgba(0, 0, 255, 1)">false</span><span style="color: rgba(0, 0, 0, 1)">
Server: Docker Engine </span>-<span style="color: rgba(0, 0, 0, 1)"> Community
Engine:
Version: </span><span style="color: rgba(128, 0, 128, 1)">19.03</span>.<span style="color: rgba(128, 0, 128, 1)">7</span><span style="color: rgba(0, 0, 0, 1)">
API version: </span><span style="color: rgba(128, 0, 128, 1)">1.40</span> (minimum version <span style="color: rgba(128, 0, 128, 1)">1.12</span><span style="color: rgba(0, 0, 0, 1)">)
Go version: go1.</span><span style="color: rgba(128, 0, 128, 1)">12.17</span><span style="color: rgba(0, 0, 0, 1)">
Git commit: 7141c199a2
Built: Wed Mar</span><span style="color: rgba(128, 0, 128, 1)">4</span> <span style="color: rgba(128, 0, 128, 1)">01</span>:<span style="color: rgba(128, 0, 128, 1)">22</span>:<span style="color: rgba(128, 0, 128, 1)">45</span> <span style="color: rgba(128, 0, 128, 1)">2020</span><span style="color: rgba(0, 0, 0, 1)">
OS</span>/Arch: linux/<span style="color: rgba(0, 0, 0, 1)">amd64
Experimental: </span><span style="color: rgba(0, 0, 255, 1)">false</span><span style="color: rgba(0, 0, 0, 1)">
containerd:
Version: </span><span style="color: rgba(128, 0, 128, 1)">1.2</span>.<span style="color: rgba(128, 0, 128, 1)">13</span><span style="color: rgba(0, 0, 0, 1)">
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: </span><span style="color: rgba(128, 0, 128, 1)">1.0</span>.<span style="color: rgba(128, 0, 128, 1)">0</span>-<span style="color: rgba(0, 0, 0, 1)">rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker</span>-<span style="color: rgba(0, 0, 0, 1)">init:
Version: </span><span style="color: rgba(128, 0, 128, 1)">0.18</span>.<span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">
GitCommit: fec3683</span></pre>
</div>
<p> </p>
<h3>四、运行hello word!</h3>
<p>先login(官方文档上说运行helloword不需要login,但会出现docker: Error response from daemon: pull access denied for hell-world, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.错误)</p>
<div class="cnblogs_Highlighter">
<pre class="brush:bash;gutter:true;"># docker run hello-world
Unable to find image 'hell-world:latest' locally
docker: Error response from daemon: pull access denied for hell-world, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: xxxxx
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
</pre>
</div>
<p> 运行hello-world</p>
<div class="cnblogs_Highlighter">
<pre class="brush:bash;gutter:true;"># docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:fc6a51919cfeb2e6763f62b6d9e8815acbf7cd2e476ea353743570610737b752
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
</pre>
</div>
<p> </p>
<p> </p>
<p> </p><br><br>
来源:https://www.cnblogs.com/zhouyu629/p/12447051.html
頁:
[1]