如何断网安装docker

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/


 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值