centos7安装docker和k8s
时间: 2023-11-01 11:59:35 浏览: 112
要在CentOS 7上安装Docker和Kubernetes,您可以按照以下步骤进行操作:
1. 删除旧版本的Docker:
```
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
```
2. 安装Docker依赖:
```
yum install -y yum-utils device-mapper-persistent-data lvm2
```
3. 添加Docker的yum源:
```
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
```
4. 更新yum缓存:
```
yum makecache fast
```
5. 安装Docker:
```
yum -y install docker-ce
```
6. 启动Docker服务:
```
systemctl start docker
```
7. 安装Kubernetes:
```
yum -y install docker kubelet kubeadm kubectl
```
8. 设置Docker和Kubelet开机自启:
```
systemctl enable docker && systemctl start docker
systemctl enable kubelet && systemctl start kubelet
```
9. 添加Kubernetes的yum源:
在/etc/yum.repos.d/目录下创建文件kubernetes.repo,然后粘贴以下内容:
```
[kubernetes]
name=Kubernetes Repo
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
enabled=1
```
10. 安装Docker和Kubernetes:
```
yum -y install docker kubeadm kubectl
```
现在您已经成功在CentOS 7上安装了Docker和Kubernetes。
阅读全文