CentOS 7 在线安装 Docker

配置阿里镜像在线安装

手动建立仓库文件docker-ce.repo并配置阿里镜像信息,并开启缓存。安装之前先查看本地是否已安装有docker。基于阿里镜像在线安装需指定参数–enablerepo=docker-ce-stable,查看完成docker(docker-1.13.1-103.git7f2769b.el7.centos.x86_64)、docker-common(docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64)、docker-client(docker-client-1.13.1-103.git7f2769b.el7.centos.x86_64三个包的安装。

阿里云镜像参考配置地址:
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/stable

阿里云镜像参考下载地址:
https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/

配置阿里镜像信息

vi /etc/yum.repos.d/docker-ce.repo
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
[docker-ce-edge]
name=Docker CE Edge - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
[docker-ce-edge-debuginfo]
name=Docker CE Edge - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug-$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
[docker-ce-edge-source]
name=Docker CE Edge - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/edge
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

开启缓存

vi /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1

在线安装

rpm -qa | grep docker
yum -y install docker --enablerepo=docker-ce-stable
rpm -qa | grep docker

在这里插入图片描述

docker --version

在这里插入图片描述
Docker卸载

 yum -y remove docker docker-common docker-client
CentOS 7上进行在线安装Docker的步骤如下: 1. 首先,确保你的机器上已经安装了Java环境。如果没有安装,请先配置Java环境。 2. 配置Docker的yum仓库。你可以选择使用国外的yum源或者国内的yum源。如果选择国外yum源,执行以下命令: ``` sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo ``` 如果选择国内yum源,执行以下命令: ``` sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo ``` 3. 安装必要的依赖包。执行以下命令: ``` sudo yum install -y yum-utils device-mapper-persistent-data lvm2 ``` 4. 可选步骤:如果你想开启edge和test仓库,可以执行以下命令。如果没有报错,可以跳过这一步。 ``` sudo yum-config-manager --enable docker-ce-edge sudo yum-config-manager --enable docker-ce-test sudo yum-config-manager --disable docker-ce-edge sudo yum-config-manager --disable docker-ce-test ``` 5. 最后,安装Docker CE。执行以下命令: ``` sudo yum install docker-ce ``` 这样,你就成功在CentOS 7上进行了在线安装Docker。 #### 引用[.reference_title] - *1* *2* [Centos7上在线安装docker的方法](https://blog.csdn.net/hsg77/article/details/90546182)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Centos 7安装Docker(线上安装)](https://blog.csdn.net/weixin_43179996/article/details/98481236)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值