Linux安装Docker
一键脚本安装
官方安装命令
curl -fsSL https://get.docker.com | bash -s docker
* 需要注意的是,官方的脚本中不支持RockuLinux
和almalinux
系统,需要自行修改一下脚本中系统版本判断函数中的代码,或者可以参考下面我修改好的
支持Rocky和Almalinux
curl -fsSL https://dl.xp.sb/get-docker.sh | bash -s docker
YUM安装
yum源设置
download docker-ce.repo file
[root@localhost ~]# wget https://download.docker.com/linux/centos/docker-ce.repo -P
change docker yum repo from tsinghua web
[root@localhost ~]# sed -i 's#download.docker.com#mirrors.tuna.tsinghua.edu.cn/docker-ce#g' /etc/yum.repos.d/docker-ce.repo
安装docker
卸载旧版本
[root@localhost ~]# yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
安装
[root@localhost ~]# yum -y install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm [root@localhost ~]# yum -y install docker-ce
启动docker
[root@zutuanxue ~]# systemctl enable docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. [root@zutuanxue ~]# systemctl start docker
验证启动
[root@localhost ~]# systemctl status docker
1.4、验证版本
[root@localhost ~]# docker -v