centos离线安装docker,docker-compose
<h1 id="安装环境">安装环境</h1><p>操作系统:Centos7.99<br>
内核版本:3.10.0-1160.el7.x86_64<br>
安装用户:root</p>
<h1 id="docker-离线安装">docker 离线安装</h1>
<blockquote>
<p>1 下载压缩包</p>
</blockquote>
<p>官网下载地址:https://download.docker.com/linux/static/stable/x86_64/</p>
<p>这里默认选择最新版本(26.0.2)。</p>
<blockquote>
<p>2 上传压缩包并解压</p>
</blockquote>
<pre><code class="language-sh">tar zxvf tar zxvf docker-26.0.2.tgz
</code></pre>
<blockquote>
<p>3 配置docker命令</p>
</blockquote>
<p>将解压后的docker命令拷贝到 /usr/bin/ 下。</p>
<pre><code class="language-sh">cp docker/* /usr/bin/
</code></pre>
<blockquote>
<p>4 创建启动单元配置</p>
</blockquote>
<p>创建启动单元配置 /etc/systemd/system/docker.service,配置示例如下</p>
<pre><code class="language-sh">
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
WantedBy=multi-user.target
</code></pre>
<blockquote>
<p>5 给启动配置赋权</p>
</blockquote>
<pre><code class="language-sh"># 给启动配置添加执行权限
chmod +x /etc/systemd/system/docker.service
# 重载单元服务配置
systemctl daemon-reload
</code></pre>
<blockquote>
<p>6 启动docker</p>
</blockquote>
<pre><code class="language-sh"># 添加 docker 开机自启
systemctl enable docker
# 启动 docker
systemctl start docker
</code></pre>
<blockquote>
<p>安装验证</p>
</blockquote>
<pre><code class="language-sh">docker -v
</code></pre>
<h1 id="docker-compose-离线安装">docker-compose 离线安装</h1>
<blockquote>
<p>1 下载压缩包</p>
</blockquote>
<p>官方下载地址:https://github.com/docker/compose/releases</p>
<p>根据实际部署系统版本选择,例如 docker-compose-linux-x86_64,这里下载下来就是一个可执行文件。</p>
<blockquote>
<p>2 将下载文件移动到docker命令所在目录下</p>
</blockquote>
<pre><code class="language-sh"># 查看 docker 命令位置,这里为 /usr/bin
which docker
# 移动并重命名
mv docker-compose-Linux-x86_64 /usr/bin/docker-compose
</code></pre>
<blockquote>
<p>3 赋予执行权限</p>
</blockquote>
<pre><code class="language-sh">chmod +x /usr/bin/docker-compose
</code></pre>
<blockquote>
<p>4 安装验证</p>
</blockquote>
<pre><code class="language-sh">docker-compose -v
</code></pre><br><br>
来源:https://www.cnblogs.com/505donkey/p/18151705
頁:
[1]