centos7 一键安装docker

虽然说 yum install -y docker也能安装上, 但是毕竟版本太老了可能会出现一些兼容性问题

博主自己总结了一些安装经验并归纳成一个安装脚本, 可以非常快速稳定的安装, 并自动配置好镜像加速源

使用的话可以之间复制粘贴使用, 也可以写进一个例如 install-docker.sh 文件里面, 然后chmod +x install-docker.sh, 然后执行 ./install-docker.sh , 就大功告成了

yum -y update ; \
yum install -y yum-utils device-mapper-persistent-data lvm2 ; \
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo ; \
yum -y install docker-ce ; \
mkdir /etc/docker ; \
echo '{"registry-mirrors":["https://hkk2f5f6.mirror.aliyuncs.com","https://dockerproxy.com","https://registry.docker-cn.com","https://mirror.baidubce.com","https://registry.cn-hangzhou.aliyuncs.com","https://docker.mirrors.ustc.edu.cn","https://mirrors.tuna.tsinghua.edu.cn"]}' > /etc/docker/daemon.json ; \
systemctl daemon-reload ; \
systemctl stop firewalld;systemctl disable firewalld ; \
systemctl restart docker;systemctl enable docker

上面的命令只是方便大家理解原理和过程, 作者封装成了链接, 链接内容其实就是上面的内容, 直接使用下面的命令可以更简单的安装:

curl -s https://static.chenlungang.com/docker/install.sh | sudo bash

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注