一键脚本安装

官方安装命令

curl -fsSL https://get.docker.com | bash -s docker

* 需要注意的是,官方的脚本中不支持RockuLinuxalmalinux系统,需要自行修改一下脚本中系统版本判断函数中的代码,或者可以参考下面我修改好的

支持Rocky和Almalinux

curl -fsSL  https://dl.xp.sb/get-docker.sh | bash -s docker

YUM安装

yum源设置

  1. download docker-ce.repo file

    [root@localhost ~]# wget https://download.docker.com/linux/centos/docker-ce.repo -P 
  2. 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

  3. 卸载旧版本

    [root@localhost ~]#  yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
  4. 安装

    [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

标签: docker, docker-compose

添加新评论