网站导航条用什么做沈阳cms模板建站
最简单的Docker离线安装教程
- 方式一 RPM 包方式
- 1. 在线下载 RPM 包
- 2. 将 RPM 包拷贝到安装机器
- 3. 安装
- 4. 启动
- 方式二 二进制安装方式(推荐)
- 1. 下载包
- 2. 将包进行解压授权
- 3. 注册 systemd
- 4. 自启和启动
一直以来在线安装 docker 到服务器上是非常方便的,但是经常会遇到服务器无法直接通互联网,因为需要我们离线安装。本文提供两种离线安装的方式。
方式一 RPM 包方式
1. 在线下载 RPM 包
先找一台可以连接互联网的电脑,下载 RPM 包,电脑的版本最好和要安装的服务器版本一致。执行如下步骤
- 下载RPM包方式&安装RPM包方式
# 安装
yum install -y yum-utils# 配置 yum docker 源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast# 下载rpm包,包括依赖都会下载
yumdownloader --resolve --downloadonly docker-ce-19.03.9 docker-ce-cli-19.03.9 docker-compose \
audit audit-libs audit-libs-python containerd.io container-selinux libcgroup python-IPy \
setools-libs checkpolicy libsemanage-python policycoreutils
2. 将 RPM 包拷贝到安装机器
怎么拷贝都行,将RPM 包放到服务器的某一个目录就行
3. 安装
# 将 rpm 包安装
rpm -ivh --replacefiles --replacepkgs *.rpm
4. 启动
systemctl enable docker && systemctl start docker后面使用跟在线安装一样了
方式二 二进制安装方式(推荐)
1. 下载包
去官方地址下载 docker 包 https://docs.docker.com/engine/install/binaries/
2. 将包进行解压授权
# 解压
tar -zxvf docker-19.03.9.tgz --strip-components=1 --directory /usr/bin/# 文件授权
chown root:root /usr/bin/containerd /usr/bin/containerd-shim /usr/bin/ctr /usr/bin/docker /usr/bin/dockerd /usr/bin/docker-init /usr/bin/docker-proxy /usr/bin/runc
3. 注册 systemd
cat > /etc/systemd/system/docker.service << EOF
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s[Install]
WantedBy=multi-user.target
EOF
4. 自启和启动
启动
systemctl daemon-reload && systemctl enable docker && systemctl start docker