Centos 7 安装 docker

docker  

docker安装

  • 设置仓库,安装所需软件包
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  • 安装依赖包 container-selinux
[root@localhost ~]# wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.119.1-1.c57a6f9.el7.noarch.rpm
[root@localhost ~]# yum install ./container-selinux-2.119.1-1.c57a6f9.el7.noarch.rpm
  • 安装Docker Engine-Community和containerd
#列出并排序存储库中可用的版本
[root@localhost ~]# yum list docker-ce --showduplicates | sort -r
#安装
[root@localhost ~]# yum install -y docker-ce docker-ce-cli containerd.io
  • 查看安装的版本号
[root@centos72 ~]# docker version
Client: Docker Engine - Community  
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:45:41 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community  
 Engine:
  Version:          20.10.12
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.12
  Git commit:       459d0df
  Built:            Mon Dec 13 11:44:05 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Docker 镜像加速器

sudo mkdir -p /etc/docker  
sudo tee /etc/docker/daemon.json <<-'EOF'  
{
  "registry-mirrors": ["https://xet0ja6w.mirror.aliyuncs.com"]
}
EOF  
sudo systemctl daemon-reload  
sudo systemctl restart docker