docker安装

7/11/2023 docker
# 安装epel更新源
yum install -y vim wget epel-release

# 使用docker仓库进行安装
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

#---------------------------------------------------------------------------------------------------------------------------------
# 安装最新版  Docker Engine-Community
sudo yum install -y docker-ce docker-ce-cli containerd.io
# or 
#---------------------------------------------------------------------------------------------------------------------------------
# 安装指定版  Docker Engine-Community
yum list docker-ce --showduplicates | sort -r
sudo yum install -y docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
#---------------------------------------------------------------------------------------------------------------------------------

# 设置docker 镜像加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
    "registry-mirrors": [
        "https://1nj0zren.mirror.aliyuncs.com",
        "https://docker.mirrors.ustc.edu.cn",
        "http://f1361db2.m.daocloud.io",
        "https://registry.docker-cn.com"
    ]
}
EOF


# 启动docker, 设置开机启动
sudo systemctl daemon-reload
sudo systemctl start docker
sudo systemctl enable docker


# 安装docker命令补全工具
yum install -y bash-completion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

参考教程 (opens new window)