CentOS 7 离线无网络环境安装Docker

需要的安装包和镜像

  • CentOS-7-x86_64-DVD-1810.iso
  • container-selinux-2.74-1.el7.noarch.rpm
  • containerd.io-1.2.5-3.1.el7.x8664.rpm
  • docker-ce-18.09.4-3.el7.x8664.rpm
  • docker-ce-cli-18.09.4-3.el7.x86_64.rpm

步骤Ⅰ:挂载CentOS镜像

mkdir /mnt/cdrom
mount -o loop /home/CentOS-7-x86_64-DVD-1810.iso /mnt/cdrom

步骤Ⅱ:更改yum源配置

mkdir /etc/yum.repos.d/back
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/back/.
cp /etc/yum.repos.d/back/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
vi /etc/yum.repos.d/CentOS-Base.repo

将所有内容替换为

[base]
name=CentOS
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=0
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-7

yum clean all

步骤Ⅲ:更新并安装相关rpm包

yum update -y
yum install -y yum-utils \ device-mapper-persistent-data \ lvm2
yum install -y container-selinux-2.74-1.el7.noarch.rpm containerd.io-1.2.5-3.1.el7.x8664.rpm docker-ce-18.09.4-3.el7.x8664.rpm docker-ce-cli-18.09.4-3.el7.x86_64.rpm

# 设置docker自启动并且启动docker
systemctl enable docker
systemctl start docker

# 查看docker版本号
docker -v

你可能感兴趣的:(CentOS 7 离线无网络环境安装Docker)