centos安装docker-ce 18.03.0-ce

1. 系统环境

Centos7  Linux version 3.10.0-327.10.1.el7.x86_64

2. docker-ce版本

18.03.0.ce-1.el7.centos.x86_64

3. 在可以联网的机器上制作docker本地安装源

3.1 安装一个虚拟机,然后在虚拟机里面安装centos7(当然,也可以一台可以联网安装了centos7系统的主机)

3.2 创建离线包存放目录,并赋予读写权限

# mkdir -p /home/docker/local 
# chmod -R 777 /home/docker/local 

3.3  创建docker的yum repository

3.3 下载离线docker-ce依赖包

注意,下面指令仅仅下载离线包到指定目录。后面要用到。

yum install --downloadonly --downloaddir=/home/docker/local yum-utils \
  device-mapper-persistent-data \
  lvm2 createrepo

3.4安装docker-ce依赖包及createrepo

yum install yum-utils \
  device-mapper-persistent-data \
  lvm2 createrepo

3.5 配置docker repository

yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

3.6 更新yum源索引

yum makecache fast

3.7下载离线docker-ce安装包

yum install --downloadonly --downloaddir=/home/docker/local docker-ce

3.8 获取安装docker需要的密匙,查看密匙文件url

[Aex@localhost ~]$ more /etc/yum.repos.d/docker-ce.repo
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
 
[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

下载密匙文件(存放到/home/docker/local下)

cd /home/docker/local
wget https://download.docker.com/linux/centos/gpg

3.9 初始化安装源repodata库

# createrepo -pdo /home/docker/local /home/docker/local
# createrepo --update /home/docker/local

/home/docker/local下面应该有如下安装包、文件及目录

container-selinux-2.42-1.gitad8f0f7.el7.noarch.rpm
createrepo-0.9.9-28.el7.noarch.rpm
device-mapper-1.02.140-8.el7.x86_64.rpm
device-mapper-event-1.02.140-8.el7.x86_64.rpm
device-mapper-event-libs-1.02.140-8.el7.x86_64.rpm
device-mapper-libs-1.02.140-8.el7.x86_64.rpm
device-mapper-persistent-data-0.7.0-0.1.rc6.el7_4.1.x8
docker-ce-18.03.0.ce-1.el7.centos.x86_64.rpm
dracut-033-502.el7_4.1.x86_64.rpm
dracut-config-rescue-033-502.el7_4.1.x86_64.rpm
dracut-network-033-502.el7_4.1.x86_64.rpm
libgudev1-219-42.el7_4.10.x86_64.rpm
libseccomp-2.3.1-3.el7.x86_64.rpm
libselinux-2.5-11.el7.x86_64.rpm
libselinux-python-2.5-11.el7.x86_64.rpm
libselinux-utils-2.5-11.el7.x86_64.rpm
libsemanage-2.5-8.el7.x86_64.rpm
libsemanage-python-2.5-8.el7.x86_64.rpm
libsepol-2.5-6.el7.x86_64.rpm
lvm2-2.02.171-8.el7.x86_64.rpm
lvm2-libs-2.02.171-8.el7.x86_64.rpm
pigz-2.3.3-1.el7.centos.x86_64.rpm
policycoreutils-2.5-17.1.el7.x86_64.rpm
policycoreutils-python-2.5-17.1.el7.x86_64.rpm
python-urlgrabber-3.10-8.el7.noarch.rpm
rpm-4.11.3-25.el7.x86_64.rpm
rpm-build-libs-4.11.3-25.el7.x86_64.rpm
rpm-libs-4.11.3-25.el7.x86_64.rpm
rpm-python-4.11.3-25.el7.x86_64.rpm
selinux-policy-3.13.1-166.el7_4.9.noarch.rpm
selinux-policy-targeted-3.13.1-166.el7_4.9.noarch.rpm
setools-libs-3.3.8-1.1.el7.x86_64.rpm
systemd-219-42.el7_4.10.x86_64.rpm
systemd-libs-219-42.el7_4.10.x86_64.rpm
systemd-python-219-42.el7_4.10.x86_64.rpm
systemd-sysv-219-42.el7_4.10.x86_64.rpm
yum-3.4.3-154.el7.centos.1.noarch.rpm
yum-utils-1.1.31-42.el7.noarch.rpm
repodata
gpg

3.10 打包导出安装源,制作离线安装源docker-local.tar.gz

# cd /home/docker/local
# tar -zcvf docker-local.tar.gz *

将docker-local.tar.gz copy到无法联网的centos7 服务器上(比如/home/docker/local目录下),并解压

# mkdir -p /home/docker/local (如果不存目录,则创建然后copy docker-local.tar.gz到此)
# cd /home/docker/local
# tar -zxvf docker-local.tar.gz

安装createrepo

rpm -ivh createrepo-0.9.9-28.el7.noarch.rpm (这个rpm安装包就是我们离线下载的安装包)

构建本地安装源

createrepo -d /home/docker/local/repodata
# yum clean all (清除缓存)
# yum makecache (创建缓存)

检查本地库是否制作成功

yum repolist

安装docker-ce

yum install docker-ce

检查是否安装成功

systemctl start docker
docker version

 

重启docker

systemctl restart docker

 

文 / Aex
LEAVE A REPLY
loading