yum 安装docker

 代码


# 设置docker仓库文件:
[root@all-in-one ~]# yum  install  yum-utils  lvm2 device-mapper-persistent-data  -y
[root@all-in-one ~]# yum-config-manager --add-repo \
 https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@all-in-one ~]# yum  repolist 
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * epel: mirrors.bfsu.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.nju.edu.cn
源标识                                                                         源名称                                                                                                状态
base/7/x86_64                                                                  CentOS-7 - Base                                                                                       10,070
docker-ce-stable/x86_64                                                        Docker CE Stable - x86_64                                                                                 73
epel/x86_64                                                                    Extra Packages for Enterprise Linux 7 - x86_64                                                        13,281
extras/7/x86_64                                                                CentOS-7 - Extras                                                                                        397
updates/7/x86_64                                                               CentOS-7 - Updates                                                                                       671
repolist: 24,492
# 安装Docker服务
[root@all-in-one ~]# yum install docker-ce docker-ce-cli containerd.io -y
# 开启dokcer服务
[root@all-in-one ~]# systemctl  enable docker.service 
[root@all-in-one ~]# systemctl  start docker.service
[root@all-in-one ~]# tee /etc/docker/daemon.json <<-'EOF'
> {
>    "registry-mirrors": ["https://7bc3o1s2.mirror.aliyuncs.com"]
> }
> EOF

{
   "registry-mirrors": ["https://7bc3o1s2.mirror.aliyuncs.com"]
}
[root@all-in-one ~]# systemctl  restart  docker.service 

或者使用官方脚本

 

当然在测试或开发环境中 Docker 官方为了简化安装流程,提供了一套便捷的安装脚本,CentOS 系统上可以使用这套脚本安装:

Inc.官方包装的Docker版本,以通过以下命令获得最大的稳定性和兼容性:
[root@hots05 ~]# curl -sSL https://get.docker.io | bash
[root@hots05 ~]# docker --version
 
 
 
[root@hots05 ~]# systemctl daemon-reload && systemctl restart docker
 
#在拉去镜像的过程中可能会超时。重新执行以下吗,命令即可。或者使用阿里云加速器下载。
[root@hots05 ~]# mkdir /etc/docker/
[root@hots05 ~]# vim /etc/docker/daemon.json
{
  "registry-mirrors": ["https://XXX.mirror.aliyuncs.com"]  
}
注:如果需要使用自己的本地私有仓库,写成如下:
{
  "registry-mirrors": ["https://XXXX.mirror.aliyuncs.com"]  
  "insecure-registries": ["192.168.1.150:5000"]
}
[root@hots05 ~]# systemctl daemon-reload  && systemctl restart docker
————————————————
版权声明:本文为CSDN博主「qq_42533216」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_42533216/article/details/115373962

具体可以参看 docker-install 的脚本:

https://github.com/docker/docker-install
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值