docker rpm安装(不能联网情况)
生产环境可能是不能联网的,当我们需要用到docker(或其他组件)的时候,就需要借助能联网的环境下载好rpm包,然后去操作系统服务器装下载好的docker RPM包。
- uname -a 确保centos7以上系统
- 修改/etc/yum.repos.d/CentOS-Base.repo 先备份一份
先找个能联网的环境下载rpm, 如下更换了yum源
#CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-7 - Base - 163.com
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-7 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/7/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
- yum update -y #更新
- yum makecache #将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度
- #添加docker源 yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
#如果可以联网那么就执行下面就可以了,yum会帮我们解决依赖。
yum install docker-ce
#如果不能联网就需要将对应操作系统的rpm包下载下来然后进行rpm安装,接下来去把rpm包传到不能联网的环境,rpm安装
#下面安装之后可以下载包到本地指定目录而不直接安装
yum install yum-plugin-downloadonly
yum install docker-ce --downloadonly --downloaddir=/home/zhangyong/yum/
然后就可以去/home/zhangyong/yum/查看 rpm包了。
cd /home/zhangyong/yum
#安装下载的rpm包
rpm -Uvh --force --nodeps ./*.rpm
#启动docker服务
systemctl start docker.service
docker -v
#卸载
yum -y remove docker docker-common docker-selinux docker-engine docker-engine-selinux container-selinux docker-ce
rm -rf /var/lib/docker/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)