<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>#Docker - Yevpt&apos;s Blog</title>
    <link>https://www.yevpt.com</link>
    <description>Yevpt&apos;s Blog 「Docker」标签下的文章</description>
    <language>zh-CN</language>
    <lastBuildDate>Tue, 16 Jun 2020 06:34:39 GMT</lastBuildDate>
    <atom:link href="https://www.yevpt.com/tags/14/feed.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Centos7 安装 Docker</title>
      <link>https://www.yevpt.com/articles/46</link>
      <guid isPermaLink="true">https://www.yevpt.com/articles/46</guid>
      <pubDate>Tue, 16 Jun 2020 06:34:39 GMT</pubDate>
      <description>虽然如今我已经在一步步降低对docker的依赖，少做了很多杀鸡用牛刀的事情，但是docker在特定的场景下依旧是非常好用，为此整理了安装的步骤和相关...</description>
      <category>工具</category>
      <content:encoded><![CDATA[<p>虽然如今已经在一步步降低对docker的依赖，少做了很多杀鸡用牛刀的事情，但是docker在很多的场景下依旧是非常好用，为此整理了安装的步骤和相关的一些配置。</p>
<h3 id="安装">安装</h3>
<h4 id="1-卸载旧版本若有">1. 卸载旧版本（若有）</h4>
<div class="md-code-wrapper"><button class="md-copy-btn md-copy-btn-abs" type="button" aria-label="复制代码"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"></rect><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"></path></svg></button><pre><code>sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
</code></pre></div>
<p> </p>
<h4 id="2-开始安装">2. 开始安装</h4>
<div class="md-code-wrapper"><button class="md-copy-btn md-copy-btn-abs" type="button" aria-label="复制代码"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"></rect><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"></path></svg></button><pre><code>sudo yum install -y yum-utils

sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
    
sudo yum install docker-ce docker-ce-cli containerd.io
# 安装docker-compose
yum install docker-compose -y
</code></pre></div>
<h4 id="3-设置开机自启并启动docker">3. 设置开机自启并启动Docker</h4>
<div class="md-code-wrapper"><button class="md-copy-btn md-copy-btn-abs" type="button" aria-label="复制代码"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"></rect><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"></path></svg></button><pre><code>sudo systemctl enable docker

sudo systemctl start docker
</code></pre></div>
<h4 id="4-运行hello-docker">4. 运行hello docker</h4>
<div class="md-code-wrapper"><button class="md-copy-btn md-copy-btn-abs" type="button" aria-label="复制代码"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"></rect><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"></path></svg></button><pre><code>sudo systemctl start docker
</code></pre></div>
<h4 id="5-查看版本">5. 查看版本</h4>
<div class="md-code-wrapper"><button class="md-copy-btn md-copy-btn-abs" type="button" aria-label="复制代码"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"></rect><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"></path></svg></button><pre><code>docker version
</code></pre></div>
<h3 id="更换国内源">更换国内源</h3>
<div class="md-code-wrapper"><button class="md-copy-btn md-copy-btn-abs" type="button" aria-label="复制代码"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"></rect><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"></path></svg></button><pre><code>sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json &#x3C;&#x3C;-'EOF'
{
  "registry-mirrors": ["https://k7en6s5m.mirror.aliyuncs.com"]
}
EOF

sudo systemctl daemon-reload
sudo systemctl restart docker
</code></pre></div>
<h3 id="命令">命令</h3>
<div class="md-code-wrapper"><button class="md-copy-btn md-copy-btn-abs" type="button" aria-label="复制代码"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"></rect><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"></path></svg></button><pre><code># 显示Docker系统信息，包括镜像和容器数
docker info
# 进入容器
docker exec -it [容器id] bash 
# 查找所有容器
docker container ls -all 
# 删除实例
docker rm -f [容器id]
</code></pre></div>
<h3 id="参考">参考</h3>
<ul>
<li><a href="https://docs.docker.com/engine/install/centos/" rel="noopener noreferrer" target="_blank">Install Docker Engine on CentOS</a></li>
</ul>]]></content:encoded>
    </item>
  </channel>
</rss>